---
title: "Analyses Study 2"
subtitle: ""
author: "Flavio Azevedo & Tamara Marques & Leticia Micheli"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
  html_document:
    toc: yes
    toc_float: yes
    css: style.css
---

<br>

```{r Document setup, include=FALSE}
knitr::opts_chunk$set(cache=TRUE,
                      small.mar=TRUE,
                      echo=FALSE,
                      warning=FALSE,
                      message = FALSE)
```

```{r libraries}
library(haven)
library(sjlabelled)
library(labelled)
library(tidyverse)
library(car)
```

<br>

## D1. 2018 Midterms Election Survey - Wave 1

```{r loading data - D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
#1.Instructions for loading the data
#A. comment the line of code below with the path on my computer or Flavio's computer
#B. copy this line of code and change the path to your computer
#C. give a name to the dataset
#D. run this code and open the data just to make sure everything is correct

######### PATH L.M. ####################
Midterm.Election.W1 <- haven::read_spss("Roper data/2018 Midterm Elections Survey - Wave 1/31115389.por")

######### PATH F.A. ####################
#Midterm.Election.W1 <- haven::read_spss("C:/Users/Flavio/Dropbox/Tamara/BLM/Roper data/2018 Midterm Elections Survey - Wave 1/31115389.por")

######### PATH T.M. ####################
#Midterm.Election.W1 <- haven::read_spss("C:/Users/tmmar/Dropbox/Tamara/BLM/Roper data/2018 Midterm Elections Survey - Wave 1/31115389.por")


#2. Instructions to generate the codebook for this dataset
#A. Change the names appropriately
#B. After running the code below, take a look at the codebook by clicking on it. Check that label/labels are given, everything looks nice.

labelled::look_for(Midterm.Election.W1) %>% dplyr::as_tibble() -> Midterm.Election.W1.codebook 

```

### DV

* Q8. Do you support or oppose the movement called Black Lives Matter?
   - (1) Strongly support
   - (2) Somewhat support
   - (3) Neither support, nor oppose
   - (4) Somewhat oppose
   - (5) Strongly oppose
   - (77) Don't know
   - (98) Skipped on web
   - (99) refused


```{r DV, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
#1. Instructions to check the variable of interest
#A. Adjust the line of code below to the right dataset name and the name of the variable (what is on the left is the data, what is on the right is the name of the variable in the dataset)
#B. Type this line of code into the console. This will let you see the values in the data for this variable and the labels. Check with the pdf documentation to see if there are any errors/problems. Copy the labels above so we have them saved in the R markdown
#
#Midterm.Election.W1$Q8 
#
#
#2. Check the question and the labels 
#sjlabelled::get_label(Midterm.Election.W1[,c("Q8")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1[,c("Q8")])  # Values check
#
#3. Checking frequencies
#table(Midterm.Election.W1$Q8, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W1$Q8, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W1$Q8, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#
#4. Creating a new dataset to manipulate variables (just add .final to name you gave above) - the name on the left is the new name, the name on the right is the old name. Check whether the new data has the same amount of info as the original data. 
Midterm.Election.W1.final <- Midterm.Election.W1
#   
#5. Creating Manipulated DV (BLM_supp) - on the left is the new name of the variable, on the right the name in the original data
Midterm.Election.W1.final$BLM_supp <- Midterm.Election.W1.final$Q8
#
#6. Selecting options that have data (= removing missing data)
#To do this you should update the line of code below only with the values that we are interested on
Midterm.Election.W1.final <- Midterm.Election.W1.final[Midterm.Election.W1.final$BLM_supp %in% c(1, 2, 3, 4, 5),]
#
#
#7. Recoding the DV (if necessary)
#Because this variable is coded in a way such that larger values mean lack of support, we need to reverse it. One way to do it is to use the largest value of a scale + 1 minus every value. Like so:

Midterm.Election.W1.final$BLM_supp <- sapply(Midterm.Election.W1.final$BLM_supp,  function(x) 6 - x)
#
#Note that after step 7, question/labels are now missing. But it shouldn't matter. We know it is now support.
#

```

### IV - Income

```{r Income, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#A. First, make sure that the data you are working with is loaded, as well as all the code for the DV of this dataset, as we will need in the next steps ONLY the new data you generated there.
#B. Adjust the line of code below to the right dataset name and the name of the variable.
#C. Type this line of code into the console. This will let you see the values in the data for this variable and the labels. Check with the pdf documentation to see if there are any errors/problems. Copy the labels above so we have them saved in the R markdown.

#Midterm.Election.W1.final$INCOME
#
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("INCOME")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("INCOME")])  # Values check
#
#3. Checking frequencies 
# A. As we saw from our work with DVs, this step is actually quite important to identify if there are values which do not appear in the labels. Here we use the final dataset. AS you remember, some answers were deleted from the original dataset because they were n/a for the DV. So, here, we want to know the proportion of the answers we do have in the final dataset we will be working with.
#
#table(Midterm.Election.W1.final$INCOME, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W1.final$INCOME, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W1.final$INCOME, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$HIncome <- Midterm.Election.W1.final$INCOME
#
#5. Selecting options that have data 
#IMPORTANT: Differently from what we did for the DVs, here we do not exclude responses that have missing info for the IVS. This would lead to us losing a lot of data, because the responses that have missing values in one IV might be different than the responses that have missing values for the other IV. So, here we will just rename these missing values to NA. 
#In this dataset, there are no missing values for income, so we can skip this step, but this may be necessary in other datasets. 
#
#Midterm.Election.W1.final[Midterm.Election.W1.final$Income %in% c(9), "Income"] <- NA
#
#
#6. Recoding the IV (if necessary)
#REMEMBER: higher numbers should generally indicate higher values of the variable (here, higher values should mean higher income, so this step is not needed, but you need to check this carefully for each variable in each dataset).
#
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W1.final.meta.income <- Midterm.Election.W1.final[, c("BLM_supp","HIncome")]
#
```

### IV - Age

```{r Age, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#A. First, make sure that the data you are working with is loaded, as well as all the code for the DV of this dataset, as we will need in the next steps ONLY the new data you generated there.
#B. Adjust the line of code below to the right dataset name and the name of the variable.
#C. Type this line of code into the console. This will let you see the values in the data for this variable and the labels. Check with the pdf documentation to see if there are any errors/problems. Copy the labels above so we have them saved in the R markdown.
#
#Midterm.Election.W1.final$AGE
#
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("AGE")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("AGE")])  # Values check
#
#3. Checking frequencies 
# A. As we saw from our work with DVs, this step is actually quite important to identify if there are values which do not appear in the labels. Here we use the final dataset. AS you remember, some answers were deleted from the original dataset because they were n/a for the DV. So, here, we want to know the proportion of the answers we do have in the final dataset we will be working with.
#
#table(Midterm.Election.W1.final$AGE, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W1.final$AGE, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W1.final$INCOME, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$RAge <- Midterm.Election.W1.final$AGE
#
#5. Selecting options that have data 
#IMPORTANT: Differently from what we did for the DVs, here we do not exclude responses that have missing info for the IVS. This would lead to us losing a lot of data, because the responses that have missing values in one IV might be different than the responses that have missing values for the other IV. So, here we will just rename these missing values to NA. 
#In this dataset, there are no missing values for income, so we can skip this step, but this may be necessary in other datasets. 
#
#Midterm.Election.W1.final[Midterm.Election.W1.final$Income %in% c(9), "Income"] <- NA
#
#
#6. Recoding the IV (if necessary)
#REMEMBER: higher numbers should generally indicate higher values of the variable (here, higher values should mean higher income, so this step is not needed, but you need to check this carefully for each variable in each dataset).
#
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W1.final.meta.age <- Midterm.Election.W1.final[, c("BLM_supp","RAge")]
#
```
<br>

### IV - Gender

```{r Gender, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#Midterm.Election.W1.final$GENDER
#
#
#2. Checking the question and the labels for the final dataset. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("GENDER")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("GENDER")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$GENDER, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W1.final$GENDER, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W1.final$GENDER, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$RGender <- Midterm.Election.W1.final$GENDER
#7. Create new data with only the variables for the correlation. Ending:  meta.income
#
Midterm.Election.W1.final.meta.gender <- Midterm.Election.W1.final[, c("BLM_supp","RGender")]
#
```

<br>

### IV - Education

```{r Education, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
Midterm.Election.W1.final$EDUC
#
#2. Checking the question and the labels for the final dataset. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("EDUC")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("EDUC")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$EDUC, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W1.final$EDUC, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W1.final$EDUC, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$REducation <- Midterm.Election.W1.final$EDUC
#
#5. Selecting options that have data 
#
#Midterm.Election.W1.final[Midterm.Election.W1.final$Education %in% c(99), "RAge"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Midterm.Election.W1.final.meta.education <- Midterm.Election.W1.final[, c("BLM_supp","REducation")]
#
```


<br>


### IV - Urbanicity

```{r Urbanicity, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Midterm.Election.W1.final$METRO
#
#2. Checking the question and the labels for the final dataset. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("METRO")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("METRO")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$METRO, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W1.final$METRO, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W1.final$METRO, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$Urbanicity <- Midterm.Election.W1.final$METRO
#
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Midterm.Election.W1.final.meta.urbanicity <- Midterm.Election.W1.final[, c("BLM_supp","Urbanicity")]
#
```


<br>



### IV - Partisanship - Republicans

```{r Partisanship - Republicans, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Republican
#Midterm.Election.W1$PID1
#Midterm.Election.W1.final$PID1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("PID1")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("PID1")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$PID1, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W1.final$PID1, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W1.final$PID1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$Partisanship_Rep <- Midterm.Election.W1.final$PID1
#
#5. Selecting options that have data 
#
# NA
Midterm.Election.W1.final[Midterm.Election.W1.final$Partisanship_Rep %in% c(3,98,99), "Partisanship_Rep"] <- NA
#
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W1.final.meta.partisanshiprep <- Midterm.Election.W1.final[, c("BLM_supp","Partisanship_Rep")]
#
```


<br>




### IV - Ideology

```{r Ideology, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Midterm.Election.W1$PHIL3
#Midterm.Election.W1.final$PHIL3
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("PHIL3")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("PHIL3")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$PHIL3, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W1.final$PHIL3, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W1.final$PHIL3, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$Ideol_Conservative <- Midterm.Election.W1.final$PHIL3
#
#5. Selecting options that have data 
#
Midterm.Election.W1.final[Midterm.Election.W1.final$Ideol_Conservative %in% c(77,98,99), "Ideol_Conservative"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W1.final.meta.ideology <- Midterm.Election.W1.final[, c("BLM_supp","Ideol_Conservative")]
#
```


<br>



### IV - Vote for House of Representatives

```{r Vote for House of Representatives, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Midterm.Election.W1$Q1
#Midterm.Election.W1.final$Q1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("Q1")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("Q1")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$Q1, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W1.final$Q1, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W1.final$Q1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$VoteHR_Republicans <- Midterm.Election.W1.final$Q1
#
#5. Selecting options that have data 
#
Midterm.Election.W1.final[Midterm.Election.W1.final$VoteHR_Republicans %in% c(3,77,98,99), "VoteHR_Republicans"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W1.final.meta.votehrrep <- Midterm.Election.W1.final[, c("BLM_supp","VoteHR_Republicans")]
#
```


<br>



### IV - Trump Approval


```{r Trump Approval, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Midterm.Election.W1.final$Q18
#Midterm.Election.W1.final$Q18A
#Midterm.Election.W1.final$Q18B

#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("Q18")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("Q18")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$Q18, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W1.final$Q18, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W1.final$Q18, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#

Midterm.Election.W1.final$Trump_App.A <- Midterm.Election.W1.final$Q18A
Midterm.Election.W1.final$Trump_App.B <- Midterm.Election.W1.final$Q18B
#
#5. Selecting options that have data 
#
Midterm.Election.W1.final[Midterm.Election.W1.final$Trump_App.A %in% c(98), "Trump_App.A"] <- NA
Midterm.Election.W1.final[Midterm.Election.W1.final$Trump_App.B %in% c(98), "Trump_App.B"] <- NA
#
#6. Recoding the IV (if necessary)
Midterm.Election.W1.final$Trump_App.A <- as.numeric(Midterm.Election.W1.final$Trump_App.A)
Midterm.Election.W1.final$Trump_App.A <- car::recode(Midterm.Election.W1.final$Trump_App.A, ' "1"="4"; "2"="3" ')
Midterm.Election.W1.final$Trump_App <- rowSums(Midterm.Election.W1.final[, c("Trump_App.A","Trump_App.B")], na.rm=T)
Midterm.Election.W1.final[Midterm.Election.W1.final$Trump_App %in% c(0), "Trump_App"] <- NA
#
#     
#
                                                              
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W1.final.meta.trumpapp <- Midterm.Election.W1.final[, c("BLM_supp","Trump_App")]
#

```





### IV - Mexico Wall - Illegal Immigration

```{r Mexico Wall - Illegal Immigration, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Midterm.Election.W1$Q11
#Midterm.Election.W1.final$Q11
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("Q11")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("Q11")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$Q11, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(Midterm.Election.W1.final$Q11, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Midterm.Election.W1.final$Q11, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$MexicoWall <- Midterm.Election.W1.final$Q11
#
#5. Selecting options that have data 
#
Midterm.Election.W1.final[Midterm.Election.W1.final$MexicoWall %in% c(77,98,99), "MexicoWall"] <- NA
#
#6. Recoding the IV (if necessary)
Midterm.Election.W1.final$MexicoWall <- sapply(Midterm.Election.W1.final$MexicoWall,  function(x) 6 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W1.final.meta.mexicowall <- Midterm.Election.W1.final[, c("BLM_supp","MexicoWall")]
#
```


<br>



### IV - Immigration - Jobs

```{r Immigration - Jobs, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Midterm.Election.W1$Q13
#Midterm.Election.W1.final$Q13
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("Q13")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("Q13")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$Q13, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(Midterm.Election.W1.final$Q13, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Midterm.Election.W1.final$Q13, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$Immigration_Jobs <- Midterm.Election.W1.final$Q13
#
#5. Selecting options that have data 
#
Midterm.Election.W1.final[Midterm.Election.W1.final$Immigration_Jobs %in% c(77,98), "Immigration_Jobs"] <- NA
#
#6. Recoding the IV (if necessary)
Midterm.Election.W1.final$Immigration_Jobs <- sapply(Midterm.Election.W1.final$Immigration_Jobs,  function(x) 6 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W1.final.meta.immigrationjobs <- Midterm.Election.W1.final[, c("BLM_supp","Immigration_Jobs")]
#
```


<br>




### IV - Illegal Immigration

```{r Illegal Immigration, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Midterm.Election.W1$Q12
#Midterm.Election.W1.final$Q12
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("Q12")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("Q12")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$Q12, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(Midterm.Election.W1.final$Q12, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Midterm.Election.W1.final$Q12, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$Immigration_Illegal <- Midterm.Election.W1.final$Q12
#
#5. Selecting options that have data 
#
Midterm.Election.W1.final[Midterm.Election.W1.final$Immigration_Illegal %in% c(77,98, 99), "Immigration_Illegal"] <- NA
#
#6. Recoding the IV (if necessary)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W1.final.meta.immigrationillegal <- Midterm.Election.W1.final[, c("BLM_supp","Immigration_Illegal")]
#
```


<br>





### IV - Marital Status

```{r Marital Status, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Married
#Midterm.Election.W1$MARITAL
#Midterm.Election.W1.final$MARITAL
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("MARITAL")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("MARITAL")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$MARITAL, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W1.final$MARITAL, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W1.final$MARITAL, useNA = "ifany")),2) # Checking %s with 2 decimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$MaritalStatus <- Midterm.Election.W1.final$MARITAL
#
#5. Selecting options that have data 
#
# NA
Midterm.Election.W1.final[Midterm.Election.W1.final$MaritalStatus %in% c(2,3,4,6), "MaritalStatus"] <- NA
#
# Never Married
Midterm.Election.W1.final[Midterm.Election.W1.final$MaritalStatus %in% c(5), "MaritalStatus"] <- 0
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W1.final.meta.maritalstatus <- Midterm.Election.W1.final[, c("BLM_supp","MaritalStatus")]
#
```


<br>



### IV - Employment Status

```{r Employment Status, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Married
#Midterm.Election.W1$EMPLOY
#Midterm.Election.W1.final$EMPLOY
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("EMPLOY")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("EMPLOY")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$EMPLOY, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W1.final$EMPLOY, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W1.final$EMPLOY, useNA = "ifany")),2) # Checking %s with 2 decimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$EmploymentStatus <- Midterm.Election.W1.final$EMPLOY
#
#5. Selecting options that have data 
#
# NA
Midterm.Election.W1.final[Midterm.Election.W1.final$EmploymentStatus %in% c(3,4,6,7), "EmploymentStatus"] <- NA
#
# Working
Midterm.Election.W1.final[Midterm.Election.W1.final$EmploymentStatus %in% c(1,2), "EmploymentStatus"] <- 1
#
# Retired
Midterm.Election.W1.final[Midterm.Election.W1.final$EmploymentStatus %in% c(5), "EmploymentStatus"] <- 0
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W1.final.meta.employmentstatus <- Midterm.Election.W1.final[, c("BLM_supp","EmploymentStatus")]
#
```


<br>




### IV - Race - Blacks

```{r Race - Blacks, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Blacks
#Midterm.Election.W1$RACETHNI
#Midterm.Election.W1.final$RACETHNI
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("RACETHNI")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("RACETHNI")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$RACETHNI, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W1.final$RACETHNI, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W1.final$RACETHNI, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$Race_Blacks <- Midterm.Election.W1.final$RACETHNI
#
#5. Selecting options that have data 
#
# NA
Midterm.Election.W1.final[Midterm.Election.W1.final$Race_Blacks %in% c(3, 5), "Race_Blacks"] <- NA
#
# Other Races
Midterm.Election.W1.final[Midterm.Election.W1.final$Race_Blacks %in% c(1,4,6), "Race_Blacks"] <- 0
#
#Blacks
Midterm.Election.W1.final[Midterm.Election.W1.final$Race_Blacks %in% c(2), "Race_Blacks"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W1.final.meta.raceblacks <- Midterm.Election.W1.final[, c("BLM_supp","Race_Blacks")]
#
```


<br>



### IV - Race - Whites

```{r Race - Whites, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Whites
#Midterm.Election.W1$RACETHNI
#Midterm.Election.W1.final$RACETHNI
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("RACETHNI")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("RACETHNI")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$RACETHNI, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W1.final$RACETHNI, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W1.final$RACETHNI, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$Race_Whites <- Midterm.Election.W1.final$RACETHNI
#
#5. Selecting options that have data 
#
# NA
Midterm.Election.W1.final[Midterm.Election.W1.final$Race_Whites %in% c(3, 5), "Race_Whites"] <- NA
#
# Other Races
Midterm.Election.W1.final[Midterm.Election.W1.final$Race_Whites %in% c(2,4,6), "Race_Whites"] <- 0
#
#Whites
#Midterm.Election.W1.final[Midterm.Election.W1.final$Race_Whites %in% c(1), "Race_Whites"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W1.final.meta.racewhites <- Midterm.Election.W1.final[, c("BLM_supp","Race_Whites")]
#
```


<br>



### IV - Race - Hispanic

```{r Race - Hispanic, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Hisp
#Midterm.Election.W1$RACETHNI
#Midterm.Election.W1.final$RACETHNI
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("RACETHNI")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("RACETHNI")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$RACETHNI, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W1.final$RACETHNI, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W1.final$RACETHNI, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$Race_Hisp <- Midterm.Election.W1.final$RACETHNI
#
#5. Selecting options that have data 
#
# NA
Midterm.Election.W1.final[Midterm.Election.W1.final$Race_Hisp %in% c(3, 5), "Race_Hisp"] <- NA
#
# Other Races
Midterm.Election.W1.final[Midterm.Election.W1.final$Race_Hisp %in% c(1,2,6), "Race_Hisp"] <- 0
#
#Hispanic
Midterm.Election.W1.final[Midterm.Election.W1.final$Race_Hisp %in% c(4), "Race_Hisp"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W1.final.meta.racehispanic <- Midterm.Election.W1.final[, c("BLM_supp","Race_Hisp")]
#
```


<br>



### IV - Race - Asians

```{r Race - Asians, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Asians
#Midterm.Election.W1$RACETHNI
#Midterm.Election.W1.final$RACETHNI
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("RACETHNI")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("RACETHNI")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$RACETHNI, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W1.final$RACETHNI, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W1.final$RACETHNI, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$Race_Asians <- Midterm.Election.W1.final$RACETHNI
#
#5. Selecting options that have data 
#
# NA
Midterm.Election.W1.final[Midterm.Election.W1.final$Race_Asians %in% c(3, 5), "Race_Asians"] <- NA
#
# Other Races
Midterm.Election.W1.final[Midterm.Election.W1.final$Race_Asians %in% c(1,2,4), "Race_Asians"] <- 0
#
#Asians
Midterm.Election.W1.final[Midterm.Election.W1.final$Race_Asians %in% c(6), "Race_Asians"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W1.final.meta.raceasians <- Midterm.Election.W1.final[, c("BLM_supp","Race_Asians")]
#
```


<br>


### IV - Systematic Racism

```{r Systematic Racism, D1. 2018 Midterms Election Survey - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Midterm.Election.W1$Q10
#Midterm.Election.W1.final$Q10
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(Midterm.Election.W1.final[,c("Q10")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W1.final[,c("Q10")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W1.final$Q10, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(Midterm.Election.W1.final$Q10, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Midterm.Election.W1.final$Q10, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W1.final$SystematicRacism <- Midterm.Election.W1.final$Q10
#
#5. Selecting options that have data 
#
Midterm.Election.W1.final[Midterm.Election.W1.final$SystematicRacism %in% c(77,98), "SystematicRacism"] <- NA
#
#6. Recoding the IV (if necessary)
Midterm.Election.W1.final$SystematicRacism <- sapply(Midterm.Election.W1.final$SystematicRacism,  function(x) 6 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W1.final.meta.systematicracism <- Midterm.Election.W1.final[, c("BLM_supp","SystematicRacism")]
#
```


<br>






## D2. 2018 Midterms Election Survey - Wave 3

```{r loading data - D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}

######### PATH L.M. ####################
Midterm.Election.W3 <- haven::read_spss("Roper data/2018 Midterm Elections Survey - Wave 3/31116762.por")

######### PATH F.A. ####################
# Midterm.Election.W3 <- haven::read_spss("C:/Users/Flavio/Dropbox/Tamara/BLM/Roper data/2018 Midterm Elections Survey - Wave 3/31116762.por")

######### PATH T.M. ####################
#Midterm.Election.W3 <- haven::read_spss("C:/Users/tmmar/Dropbox/Tamara/BLM/Roper data/2018 Midterm Elections Survey - Wave 3/31116762.por")


labelled::look_for(Midterm.Election.W3) %>% dplyr::as_tibble() -> Midterm.Election.W3.codebook 

```

### DV

* Q5. Do you support or oppose the movement called Black Lives Matter?
   - (1) Strongly support
   - (2) Somewhat support
   - (3) Neither support, nor oppose
   - (4) Somewhat oppose
   - (5) Strongly oppose
   - (NA) Don't know/Skipped on web; refused

```{r DV, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}

Midterm.Election.W3$Q5 

#
#2. Check the question and the labels 
sjlabelled::get_label(Midterm.Election.W3[,c("Q5")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3[,c("Q5")])  # Values check
#
#3. Checking frequencies
table(Midterm.Election.W3$Q5, useNA = "ifany")                      # Checking frequencies
prop.table(table(Midterm.Election.W3$Q5, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Midterm.Election.W3$Q5, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating a new dataset to manipulate variables 
Midterm.Election.W3.final <- Midterm.Election.W3
#
#5. Creating Manipulated DV (BLM_supp) 
Midterm.Election.W3.final$BLM_supp <- Midterm.Election.W3.final$Q5
#
#6. Selecting options that have data (= removing missing data)
#
Midterm.Election.W3.final <- Midterm.Election.W3.final[Midterm.Election.W3.final$BLM_supp %in% c(1, 2, 3, 4, 5),]
#
#7. Recoding the DV (if necessary)
#
Midterm.Election.W3.final$BLM_supp <- sapply(Midterm.Election.W3.final$BLM_supp,  function(x) 6 - x)

```

### IV - Income

```{r Income, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Check the variable of interest

#Midterm.Election.W3.final$INCOME
#
#2. Check the question and the labels for the final dataset
#sjlabelled::get_label(Midterm.Election.W3.final[,c("INCOME")])   # Values check
#sjlabelled::get_labels(Midterm.Election.W3.final[,c("INCOME")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W3.final$INCOME, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W3.final$INCOME, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W3.final$INCOME, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$HIncome <- Midterm.Election.W3.final$INCOME
#
#5. Selecting options that have data 
#
#Midterm.Election.W1.final[Midterm.Election.W1.final$Income %in% c(9), "Income"] <- NA

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.income <- Midterm.Election.W3.final[, c("BLM_supp","HIncome")]
#

```

### IV - Age

```{r Age, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
Midterm.Election.W3.final$AGE
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("AGE")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("AGE")])  # Values check
#
#3. Checking frequencies 
#
table(Midterm.Election.W3.final$AGE, useNA = "ifany")                      # Checking frequencies
prop.table(table(Midterm.Election.W3.final$AGE, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Midterm.Election.W3.final$INCOME, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$RAge <- Midterm.Election.W3.final$AGE
#
#5. Selecting options that have data 
#
#Midterm.Election.W1.final[Midterm.Election.W3.final$Income %in% c(9), "Income"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.age <- Midterm.Election.W3.final[, c("BLM_supp","RAge")]
#
```


<br>

### IV - Gender

```{r Gender, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
Midterm.Election.W3.final$GENDER
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("GENDER")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("GENDER")])  # Values check
#
#3. Checking frequencies 
#
table(Midterm.Election.W3.final$GENDER, useNA = "ifany")                      # Checking frequencies
prop.table(table(Midterm.Election.W3.final$GENDER, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Midterm.Election.W3.final$GENDER, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$RGender <- Midterm.Election.W3.final$GENDER
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.gender <- Midterm.Election.W3.final[, c("BLM_supp","RGender")]
#
```


<br>


### IV - Education

```{r Education, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
Midterm.Election.W3.final$EDUC
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("EDUC")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("EDUC")])  # Values check
#
#3. Checking frequencies 
#
table(Midterm.Election.W3.final$EDUC, useNA = "ifany")                      # Checking frequencies
prop.table(table(Midterm.Election.W3.final$EDUC, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Midterm.Election.W3.final$EDUC, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$REducation <- Midterm.Election.W3.final$EDUC
#
#5. Selecting options that have data 
#
#Midterm.Election.W1.final[Midterm.Election.W3.final$Income %in% c(9), "Income"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.education <- Midterm.Election.W3.final[, c("BLM_supp","REducation")]
#
```


<br>

### IV - Urbanicity

```{r Urbanicity, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
Midterm.Election.W3.final$METRO
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("METRO")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("METRO")])  # Values check
#
#3. Checking frequencies 
#
table(Midterm.Election.W3.final$METRO, useNA = "ifany")                      # Checking frequencies
prop.table(table(Midterm.Election.W3.final$METRO, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Midterm.Election.W3.final$METRO, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$Urbanicity <- Midterm.Election.W3.final$METRO
#
#Missing Data
#Midterm.Election.W3.final[Midterm.Election.W3.final$Urbanicity %in% c(9), "RAge"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Midterm.Election.W3.final.meta.urbanicity <- Midterm.Election.W3.final[, c("BLM_supp","Urbanicity")]
#
```


<br>


### IV - Partisanship - Republicans

```{r Partisanship - Republicans, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Republican
#Midterm.Election.W3$PID1
Midterm.Election.W3.final$PID1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("PID1")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("PID1")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W3.final$PID1, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W3.final$PID1, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W3.final$PID1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$Partisanship_Rep <- Midterm.Election.W3.final$PID1
#
#5. Selecting options that have data 
#
# NA
Midterm.Election.W3.final[Midterm.Election.W3.final$Partisanship_Rep %in% c(3,98), "Partisanship_Rep"] <- NA
#
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.partisanshiprep <- Midterm.Election.W3.final[, c("BLM_supp","Partisanship_Rep")]
#
```


<br>





### IV - Ideology

```{r Ideology, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Midterm.Election.W3$PHIL3
Midterm.Election.W3.final$PHIL3
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("PHIL3")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("PHIL3")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W3.final$PHIL3, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W3.final$PHIL3, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W3.final$PHIL3, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$Ideol_Conservative <- Midterm.Election.W3.final$PHIL3
#
#5. Selecting options that have data 
#
Midterm.Election.W3.final[Midterm.Election.W3.final$Ideol_Conservative %in% c(98), "Ideol_Conservative"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.ideology <- Midterm.Election.W3.final[, c("BLM_supp","Ideol_Conservative")]
#
```


<br>




### IV - Vote for House of Representatives

```{r Vote for House of Representatives, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Midterm.Election.W3$Q1
Midterm.Election.W3.final$Q1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("Q1")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("Q1")])  # Values check
#
#3. Checking frequencies 
#
table(Midterm.Election.W3.final$Q1, useNA = "ifany")                      # Checking frequencies
prop.table(table(Midterm.Election.W3.final$Q1, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Midterm.Election.W3.final$Q1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$VoteHR_Republicans <- Midterm.Election.W3.final$Q1
#
#5. Selecting options that have data 
#
Midterm.Election.W3.final[Midterm.Election.W3.final$VoteHR_Republicans %in% c(3,98), "VoteHR_Republicans"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.votehrrep <- Midterm.Election.W3.final[, c("BLM_supp","VoteHR_Republicans")]
#
```


<br>

### IV - Trump Approval


```{r Trump Approval, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Midterm.Election.W1.final$Q18
Midterm.Election.W3.final$Q22A
Midterm.Election.W3.final$Q22B

#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("Q22")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("Q22")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W3.final$Q22, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W3.final$Q22, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W3.final$Q22, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#

Midterm.Election.W3.final$Trump_App.A <- Midterm.Election.W3.final$Q22A
Midterm.Election.W3.final$Trump_App.B <- Midterm.Election.W3.final$Q22B
#
#5. Selecting options that have data 
#
Midterm.Election.W3.final[Midterm.Election.W3.final$Trump_App.A %in% c(98), "Trump_App.A"] <- NA
Midterm.Election.W3.final[Midterm.Election.W3.final$Trump_App.B %in% c(98), "Trump_App.B"] <- NA
#
#6. Recoding the IV (if necessary)
Midterm.Election.W3.final$Trump_App.A <- as.numeric(Midterm.Election.W3.final$Trump_App.A)
Midterm.Election.W3.final$Trump_App.A <- car::recode(Midterm.Election.W3.final$Trump_App.A, ' "1"="4"; "2"="3" ')
Midterm.Election.W3.final$Trump_App <- rowSums(Midterm.Election.W3.final[, c("Trump_App.A","Trump_App.B")], na.rm=T)
Midterm.Election.W3.final[Midterm.Election.W3.final$Trump_App %in% c(0), "Trump_App"] <- NA
#
#     
#
                                                              
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.trumpapp <- Midterm.Election.W3.final[, c("BLM_supp","Trump_App")]
#

```




### IV - Mexico Wall - Illegal Immigration

```{r Mexico Wall - Illegal Immigration, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Midterm.Election.W3$Q8
Midterm.Election.W3.final$Q8
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("Q8")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("Q8")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W3.final$Q8, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W3.final$Q8, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W3.final$Q8, useNA = "ifany")),2) # Checking s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$MexicoWall <- Midterm.Election.W3.final$Q8
#
#5. Selecting options that have data 
#
Midterm.Election.W3.final[Midterm.Election.W3.final$MexicoWall %in% c(98), "MexicoWall"] <- NA
#
#6. Recoding the IV (if necessary)
Midterm.Election.W3.final$MexicoWall <- sapply(Midterm.Election.W3.final$MexicoWall,  function(x) 6 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.mexicowall <- Midterm.Election.W3.final[, c("BLM_supp","MexicoWall")]
#
```


<br>




### IV - Immigration - Jobs

```{r Immigration - Jobs, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Midterm.Election.W3$Q10
Midterm.Election.W3.final$Q10
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("Q10")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("Q10")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W3.final$Q10, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(Midterm.Election.W3.final$Q10, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Midterm.Election.W3.final$Q10, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$Immigration_Jobs <- Midterm.Election.W3.final$Q10
#
#5. Selecting options that have data 
#
Midterm.Election.W3.final[Midterm.Election.W3.final$Immigration_Jobs %in% c(98), "Immigration_Jobs"] <- NA
#
#6. Recoding the IV (if necessary)
Midterm.Election.W3.final$Immigration_Jobs <- sapply(Midterm.Election.W3.final$Immigration_Jobs,  function(x) 6 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.immigrationjobs <- Midterm.Election.W3.final[, c("BLM_supp","Immigration_Jobs")]
#
```


<br>


### IV - Illegal Immigration

```{r Illegal Immigration, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Midterm.Election.W3$Q9
Midterm.Election.W3.final$Q9
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("Q9")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("Q9")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W3.final$Q9, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(Midterm.Election.W3.final$Q9, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Midterm.Election.W3.final$Q9, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$Immigration_Illegal <- Midterm.Election.W3.final$Q9
#
#5. Selecting options that have data 
#
Midterm.Election.W3.final[Midterm.Election.W3.final$Immigration_Illegal %in% c(98), "Immigration_Illegal"] <- NA
#
#6. Recoding the IV (if necessary)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.immigrationillegal <- Midterm.Election.W3.final[, c("BLM_supp","Immigration_Illegal")]
#
```


<br>





### IV - Marital Status

```{r Marital Status, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Married
Midterm.Election.W3.final$MARITAL
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("MARITAL")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("MARITAL")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W3.final$MARITAL, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W3.final$MARITAL, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W3.final$MARITAL, useNA = "ifany")),2) # Checking %s with 2 decimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$MaritalStatus <- Midterm.Election.W3.final$MARITAL
#
#5. Selecting options that have data 
#
# NA
Midterm.Election.W3.final[Midterm.Election.W3.final$MaritalStatus %in% c(2,3,4,6), "MaritalStatus"] <- NA
#
# Never Married
Midterm.Election.W3.final[Midterm.Election.W3.final$MaritalStatus %in% c(5), "MaritalStatus"] <- 0
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.maritalstatus <- Midterm.Election.W1.final[, c("BLM_supp","MaritalStatus")]
#
```


<br>


### IV - Employment Status

```{r Employment Status, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Married
#Midterm.Election.W3$EMPLOY
Midterm.Election.W3.final$EMPLOY
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("EMPLOY")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("EMPLOY")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W3.final$EMPLOY, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W3.final$EMPLOY, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W3.final$EMPLOY, useNA = "ifany")),2) # Checking %s with 2 decimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$EmploymentStatus <- Midterm.Election.W3.final$EMPLOY
#
#5. Selecting options that have data 
#
# NA
Midterm.Election.W3.final[Midterm.Election.W3.final$EmploymentStatus %in% c(3,4,6,7), "EmploymentStatus"] <- NA
#
# Working
Midterm.Election.W3.final[Midterm.Election.W3.final$EmploymentStatus %in% c(1,2), "EmploymentStatus"] <- 1
#
# Retired
Midterm.Election.W3.final[Midterm.Election.W3.final$EmploymentStatus %in% c(5), "EmploymentStatus"] <- 0
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.employmentstatus <- Midterm.Election.W3.final[, c("BLM_supp","EmploymentStatus")]
#
```


<br>



### IV - Race - Blacks

```{r Race - Blacks, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Blacks
#Midterm.Election.W3$RACETHNI
Midterm.Election.W3.final$RACETHNI
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("RACETHNI")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("RACETHNI")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W3.final$RACETHNI, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W3.final$RACETHNI, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W3.final$RACETHNI, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$Race_Blacks <- Midterm.Election.W3.final$RACETHNI
#
#5. Selecting options that have data 
#
# NA
Midterm.Election.W3.final[Midterm.Election.W3.final$Race_Blacks %in% c(3, 5), "Race_Blacks"] <- NA
#
# Other races
Midterm.Election.W3.final[Midterm.Election.W3.final$Race_Blacks %in% c(1,4,6), "Race_Blacks"] <- 0
#
#Blacks
Midterm.Election.W3.final[Midterm.Election.W3.final$Race_Blacks %in% c(2), "Race_Blacks"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.raceblacks <- Midterm.Election.W3.final[, c("BLM_supp","Race_Blacks")]
#
```


<br>



### IV - Race - Whites

```{r Race - Whites, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Whites
#Midterm.Election.W3$RACETHNI
Midterm.Election.W3.final$RACETHNI
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("RACETHNI")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("RACETHNI")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W3.final$RACETHNI, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W3.final$RACETHNI, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W3.final$RACETHNI, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$Race_Whites <- Midterm.Election.W3.final$RACETHNI
#
#5. Selecting options that have data 
#
# NA
Midterm.Election.W3.final[Midterm.Election.W3.final$Race_Whites %in% c(3, 5), "Race_Whites"] <- NA
#
# Other races
Midterm.Election.W3.final[Midterm.Election.W3.final$Race_Whites %in% c(2,4,6), "Race_Whites"] <- 0
#
#Whites
#Midterm.Election.W3.final[Midterm.Election.W3.final$Race_Whites %in% c(1), "Race_Whites"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.racewhites <- Midterm.Election.W3.final[, c("BLM_supp","Race_Whites")]
#
```


<br>


### IV - Race - Hispanics

```{r Race - Hispanics, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Hisp
#Midterm.Election.W3$RACETHNI
Midterm.Election.W3.final$RACETHNI
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("RACETHNI")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("RACETHNI")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W3.final$RACETHNI, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W3.final$RACETHNI, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W3.final$RACETHNI, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$Race_Hisp <- Midterm.Election.W3.final$RACETHNI
#
#5. Selecting options that have data 
#
# NA
Midterm.Election.W3.final[Midterm.Election.W3.final$Race_Hisp %in% c(3, 5), "Race_Hisp"] <- NA
#
# Other races
Midterm.Election.W3.final[Midterm.Election.W3.final$Race_Hisp %in% c(1,2,6), "Race_Hisp"] <- 0
#
#Hisp
Midterm.Election.W3.final[Midterm.Election.W3.final$Race_Hisp %in% c(4), "Race_Hisp"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.racehispanic <- Midterm.Election.W3.final[, c("BLM_supp","Race_Hisp")]
#
```


<br>



### IV - Race - Asians

```{r Race - Asians, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Asians
#Midterm.Election.W3$RACETHNI
Midterm.Election.W3.final$RACETHNI
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("RACETHNI")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("RACETHNI")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W3.final$RACETHNI, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Midterm.Election.W3.final$RACETHNI, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Midterm.Election.W3.final$RACETHNI, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$Race_Asians <- Midterm.Election.W3.final$RACETHNI
#
#5. Selecting options that have data 
#
# NA
Midterm.Election.W3.final[Midterm.Election.W3.final$Race_Asians %in% c(3, 5), "Race_Asians"] <- NA
#
# Other races
Midterm.Election.W3.final[Midterm.Election.W3.final$Race_Asians %in% c(1,2,4), "Race_Asians"] <- 0
#
#Asians
Midterm.Election.W3.final[Midterm.Election.W3.final$Race_Asians %in% c(6), "Race_Asians"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.raceasians <- Midterm.Election.W3.final[, c("BLM_supp","Race_Asians")]
#
```


<br>


### IV - Systematic Racism

```{r Systematic Racism, D2. 2018 Midterms Election Survey - Wave 3, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Midterm.Election.W3.final$Q7
Midterm.Election.W3.final$Q7
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Midterm.Election.W3.final[,c("Q7")])   # Values check
sjlabelled::get_labels(Midterm.Election.W3.final[,c("Q7")])  # Values check
#
#3. Checking frequencies 
#
#table(Midterm.Election.W3.final$Q7, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(Midterm.Election.W3.final$Q7, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Midterm.Election.W3.final$Q7, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Midterm.Election.W3.final$SystematicRacism <- Midterm.Election.W3.final$Q7
#
#5. Selecting options that have data 
#
Midterm.Election.W3.final[Midterm.Election.W3.final$SystematicRacism %in% c(98), "SystematicRacism"] <- NA
#
#6. Recoding the IV (if necessary)
Midterm.Election.W3.final$SystematicRacism <- sapply(Midterm.Election.W3.final$SystematicRacism,  function(x) 6 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Midterm.Election.W3.final.meta.systematicracism <- Midterm.Election.W3.final[, c("BLM_supp","SystematicRacism")]
#
```


<br>



## D5. CBS NewsNew York Times Poll 2016

```{r loading data - D5. CBS NewsNew York Times Poll 2016, include=FALSE}

######### PATH L.M. ####################
CBS.2016 <- haven::read_spss("Roper data/CBS NewsNew York Times Poll 2016 Presidential CampaignEconomyImmigrationPolice and Race Relations in the U.S/31102964.por")

######### PATH F.A. ####################
# CBS.2016 <- haven::read_spss("C:/Users/Flavio/Dropbox/Tamara/BLM/Roper data/CBS NewsNew York Times Poll 2016 Presidential CampaignEconomyImmigrationPolice and Race Relations in the U.S/31102964.por")

######### PATH T.M. ####################
#CBS.2016 <- haven::read_spss("C:/Users/tmmar/Dropbox/Tamara/BLM/Roper data/CBS NewsNew York Times Poll 2016 Presidential CampaignEconomyImmigrationPolice and Race Relations in the U.S/31102964.por")


labelled::look_for(CBS.2016) %>% dplyr::as_tibble() -> CBS.2016.codebook 

```

### DV

* Q41. (BLMAGREE) From what you have heard or seen about Black Lives Matter, do you mostly agree or mostly disagree with Black Lives Matter, or don't you have an opinion either way?.
   - (1) Mostly agree
   - (2) Mostly disagree
   - (3) Don't have an opinion either way
   - (9) Don't know/No answer

```{r DV, D5. CBS NewsNew York Times Poll 2016, include=FALSE}

CBS.2016$BLMAGREE
#
#2. Check the question and the labels 
sjlabelled::get_label(CBS.2016[,c("BLMAGREE")])   # Values check
sjlabelled::get_labels(CBS.2016[,c("BLMAGREE")])  # Values check
#
#3. Checking frequencies
table(CBS.2016$BLMAGREE, useNA = "ifany")                      # Checking frequencies
prop.table(table(CBS.2016$BLMAGREE, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CBS.2016$BLMAGREE, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating a new dataset to manipulate variables 
CBS.2016.final <- CBS.2016
#
#5. Creating Manipulated DV (BLM_supp) 
CBS.2016.final$BLM_supp <- CBS.2016.final$BLMAGREE
#
#6. Selecting options that have data (= removing missing data)
#
CBS.2016.final <- CBS.2016.final[CBS.2016.final$BLM_supp %in% c(1, 2),]
#
#7. Recoding the DV (if necessary)
#
CBS.2016.final$BLM_supp <- sapply(CBS.2016.final$BLM_supp,  function(x) 3 - x)


```

### IV - Income

```{r Income, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. checking the variable of interest
#
CBS.2016.final$INCOME
#
#2. Checking the question and the labels for the final dataset.. 
sjlabelled::get_label(CBS.2016.final[,c("INCOME")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("INCOME")])  # Values check
#
#3. Checking frequencies 
#
table(CBS.2016.final$INCOME, useNA = "ifany")                      # Checking frequencies
prop.table(table(CBS.2016.final$INCOME, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CBS.2016.final$INCOME, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$HIncome <- CBS.2016.final$INCOME
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$HIncome %in% c(9), "HIncome"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
CBS.2016.final.meta.income <- CBS.2016.final[, c("BLM_supp","HIncome")]
#
```

### IV - Age

```{r Age, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
CBS.2016.final$AGE
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(CBS.2016.final[,c("AGE")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("AGE")])  # Values check
#
#3. Checking frequencies 
#
table(CBS.2016.final$AGE, useNA = "ifany")                      # Checking frequencies
prop.table(table(CBS.2016.final$AGE, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CBS.2016.final$AGE, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$RAge <- CBS.2016.final$AGE
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$RAge %in% c(99), "RAge"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
CBS.2016.final.meta.age <- CBS.2016.final[, c("BLM_supp","RAge")]
#
```


<br>

### IV - Gender


```{r Gender, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
CBS.2016.final$SEX
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(CBS.2016.final[,c("SEX")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("SEX")])  # Values check
#
#3. Checking frequencies 
#
table(CBS.2016.final$SEX, useNA = "ifany")                      # Checking frequencies
prop.table(table(CBS.2016.final$SEX, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CBS.2016.final$SEX, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$RGender <- CBS.2016.final$SEX
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
CBS.2016.final.meta.gender <- CBS.2016.final[, c("BLM_supp","RGender")]
#
```


<br>


### IV - Education

```{r Education, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
CBS.2016.final$EDUC
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(CBS.2016.final[,c("EDUC")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("EDUC")])  # Values check
#
#3. Checking frequencies 
#
table(CBS.2016.final$EDUC, useNA = "ifany")                      # Checking frequencies
prop.table(table(CBS.2016.final$EDUC, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CBS.2016.final$EDUC, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$REducation <- CBS.2016.final$EDUC
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$REducation %in% c(9), "REducation"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
CBS.2016.final.meta.education <- CBS.2016.final[, c("BLM_supp","REducation")]
#
```


<br>

### IV - Partisanship - Republicans

```{r Partisanship - Republicans, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Republican
#CBS.2016$PRTY
CBS.2016.final$PRTY
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("PRTY")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("PRTY")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$PRTY, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CBS.2016.final$PRTY, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CBS.2016.final$PRTY, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$Partisanship_Rep <- CBS.2016.final$PRTY
#
#5. Selecting options that have data 
#
# NA
CBS.2016.final[CBS.2016.final$Partisanship_Rep %in% c(9), "Partisanship_Rep"] <- NA
#
#6. Recoding the IV (if necessary)
CBS.2016.final$Partisanship_Rep <- as.numeric(CBS.2016.final$Partisanship_Rep)
CBS.2016.final$Partisanship_Rep <- car::recode(CBS.2016.final$Partisanship_Rep, ' "1"="3"; "2"="1"; "3"="2" ')
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.partisanshiprep <- CBS.2016.final[, c("BLM_supp","Partisanship_Rep")]
#
```


<br>


### IV - Ideology

```{r Ideology, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CBS.2016$PPHL3
CBS.2016.final$PPHL3
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("PPHL3")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("PPHL3")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$PPHL3, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CBS.2016.final$PPHL3, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CBS.2016.final$PPHL3, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$Ideol_Conservative <- CBS.2016.final$PPHL3
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$Ideol_Conservative %in% c(9), "Ideol_Conservative"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.ideology <- CBS.2016.final[, c("BLM_supp","Ideol_Conservative")]
#
```


<br>


### IV - Police Misconduct

```{r Police Misconduct, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CBS.2016$COPRACED
CBS.2016.final$COPRACED
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("COPRACED")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("COPRACED")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$COPRACED, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CBS.2016.final$COPRACED, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CBS.2016.final$COPRACED, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$PoliceMisc <- CBS.2016.final$COPRACED
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$PoliceMisc %in% c(9), "PoliceMisc"] <- NA
#
#6. Recoding the IV (if necessary)
CBS.2016.final$PoliceMisc <- as.numeric(CBS.2016.final$PoliceMisc)
CBS.2016.final$PoliceMisc <- car::recode(CBS.2016.final$PoliceMisc, ' "1"="3"; "2"="1"; "3"="2" ')

#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.policemisconduct <- CBS.2016.final[, c("BLM_supp","PoliceMisc")]
#
```


<br>



### IV - Registered to Vote

```{r Registered to Vote, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CBS.2016$REG
CBS.2016.final$REG
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("REG")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("REG")])  # Values check
#
#3. Checking frequencies 
#
table(CBS.2016.final$REG, useNA = "ifany")                      # Checking frequencies
prop.table(table(CBS.2016.final$REG, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CBS.2016.final$REG, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$VoteReg <- CBS.2016.final$REG
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$VoteReg %in% c(9), "VoteReg"] <- NA
#
#6. Recoding the IV (if necessary)
CBS.2016.final$VoteReg <- sapply(CBS.2016.final$VoteReg,  function(x) 3 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.votereg <- CBS.2016.final[, c("BLM_supp","VoteReg")]
#
```


<br>




### IV - Vote Intention

```{r Vote Intention, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CBS.2016$LKLYVOTE
CBS.2016.final$LKLYVOTE
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("LKLYVOTE")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("LKLYVOTE")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$LKLYVOTE, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CBS.2016.final$LKLYVOTE, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CBS.2016.final$LKLYVOTE, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$VoteInt <- CBS.2016.final$LKLYVOTE
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$VoteInt %in% c(9), "VoteInt"] <- NA
#
#6. Recoding the IV (if necessary)
CBS.2016.final$VoteInt <- sapply(CBS.2016.final$VoteInt,  function(x) 5 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.voteint <- CBS.2016.final[, c("BLM_supp","VoteInt")]
#
```


<br>



### IV - Obama Approval

```{r Obama Approval, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Obama Approval
#CBS.2016$OBAMAAPP
CBS.2016.final$OBAMAAPP
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("OBAMAAPP")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("OBAMAAPP")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$OBAMAAPP, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CBS.2016.final$OBAMAAPP, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CBS.2016.final$OBAMAAPP, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$Obama_App <- CBS.2016.final$OBAMAAPP
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$Obama_App %in% c(9), "Obama_App"] <- NA
#
#6. Recoding the IV (if necessary)
CBS.2016.final$Obama_App <- sapply(CBS.2016.final$Obama_App,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.obamaapp <- CBS.2016.final[, c("BLM_supp","Obama_App")]
#
```


<br>



### IV - Hillary - Favorability

```{r Hillary - Favorability, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
# Favorability towards Hillary Clinton
CBS.2016$HRCFAV
CBS.2016.final$HRCFAV
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("HRCFAV")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("HRCFAV")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$HRCFAV, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CBS.2016.final$HRCFAV, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CBS.2016.final$HRCFAV, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$Hillary_Fav <- CBS.2016.final$HRCFAV
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$Hillary_Fav %in% c(3,4,9), "Hillary_Fav"] <- NA
#
#6. Recoding the IV (if necessary)
CBS.2016.final$Hillary_Fav <- sapply(CBS.2016.final$Hillary_Fav,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.hillaryfav <- CBS.2016.final[, c("BLM_supp","Hillary_Fav")]
#
```


<br>


### IV - Trump - Favorability

```{r Trump - Favorability, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
# Favorability towards Trump
#CBS.2016$TRUMPFAV
CBS.2016.final$TRUMPFAV
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("TRUMPFAV")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("TRUMPFAV")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$TRUMPFAV, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CBS.2016.final$TRUMPFAV, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CBS.2016.final$TRUMPFAV, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$Trump_Fav <- CBS.2016.final$TRUMPFAV
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$Trump_Fav %in% c(3,4,9), "Trump_Fav"] <- NA
#
#6. Recoding the IV (if necessary)
CBS.2016.final$Trump_Fav <- sapply(CBS.2016.final$Trump_Fav,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.trumpfav <- CBS.2016.final[, c("BLM_supp","Trump_Fav")]
#
```


<br>


### IV - Vote 2016 - Clinton VS TRUMP

```{r Vote 2016 - Clinton VS Trump, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
# Favorability towards Trump
#CBS.2016$HRCTRUMP
CBS.2016.final$HRCTRUMP
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("HRCTRUMP")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("HRCTRUMP")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$HRCTRUMP, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CBS.2016.final$HRCTRUMP, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CBS.2016.final$HRCTRUMP, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$Vote16_ClintonVSTrump <- CBS.2016.final$HRCTRUMP
#
#5. Selecting options that have data 
CBS.2016.final[CBS.2016.final$Vote16_ClintonVSTrump %in% c(3,4,5,9), "Vote16_ClintonVSTrump"] <- NA
#
#6. Recoding the IV (if necessary)
#CBS.2016.final$Vote16_ClintonVSTrump <- sapply(CBS.2016.final$Vote16_ClintonVSTrump,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.vote16clintonvstrump <- CBS.2016.final[, c("BLM_supp","Vote16_ClintonVSTrump")]
#
```


<br>


### IV - Mexico Wall - Illegal Immigration

```{r Mexico Wall - Illegal Immigration, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CBS.2016$MEXICOWA
CBS.2016.final$MEXICOWA
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("MEXICOWA")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("MEXICOWA")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$MEXICOWA, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CBS.2016.final$MEXICOWA, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CBS.2016.final$MEXICOWA, useNA = "ifany")),2) # Checking s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$MexicoWall <- CBS.2016.final$MEXICOWA
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$MexicoWall %in% c(9), "MexicoWall"] <- NA
#
#6. Recoding the IV (if necessary)
CBS.2016.final$MexicoWall <- sapply(CBS.2016.final$MexicoWall,  function(x) 3 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.mexicowall <- CBS.2016.final[, c("BLM_supp","MexicoWall")]
#
```


<br>



### IV - Immigration - Jobs

```{r Immigration - Jobs, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#Support - Highest
#CBS.2016$IMMTAKEJ
CBS.2016.final$IMMTAKEJ
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("IMMTAKEJ")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("IMMTAKEJ")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$IMMTAKEJ, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(CBS.2016.final$IMMTAKEJ, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(CBS.2016.final$IMMTAKEJ, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$Immigration_Jobs <- CBS.2016.final$IMMTAKEJ
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$Immigration_Jobs %in% c(3,9), "Immigration_Jobs"] <- NA
#
#6. Recoding the IV (if necessary)
CBS.2016.final$Immigration_Jobs <- sapply(CBS.2016.final$Immigration_Jobs,  function(x) 3 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.immigrationjobs <- CBS.2016.final[, c("BLM_supp","Immigration_Jobs")]
#
```


<br>



### IV - Illegal Immigration

```{r Illegal Immigration, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest

#CBS.2016$IMMTAKEJ
CBS.2016.final$IMM3PRT
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("IMM3PRT")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("IMM3PRT")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$IMM3PRT, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(CBS.2016.final$IMM3PRT, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(CBS.2016.final$IMM3PRT, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$Immigration_Illegal <- CBS.2016.final$IMM3PRT
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$Immigration_Illegal %in% c(9), "Immigration_Illegal"] <- NA
#
#6. Recoding the IV (if necessary)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.immigrationillegal <- CBS.2016.final[, c("BLM_supp","Immigration_Illegal")]
#
```


<br>



### IV - Race Relations - Better/Worse

```{r Race Relations, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#Better- Highest
#CBS.2016$RACERELD
CBS.2016.final$RACERELD
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("RACERELD")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("RACERELD")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$RACERELD, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(CBS.2016.final$RACERELD, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(CBS.2016.final$RACERELD, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$RaceRelations_Better <- CBS.2016.final$RACERELD
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$RaceRelations_Better %in% c(9), "RaceRelations_Better"] <- NA
#
#6. Recoding the IV (if necessary)
#CBS.2016.final$RaceRelations_Better <- sapply(CBS.2016.final$RaceRelations_Better,  function(x) 3 - x)
CBS.2016.final$RaceRelations_Better <- as.numeric(CBS.2016.final$RaceRelations_Better)
CBS.2016.final$RaceRelations_Better <- car::recode(CBS.2016.final$RaceRelations_Better, ' "1"="3"; "2"="1"; "3"="2" ')

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.racerelationsbetter <- CBS.2016.final[, c("BLM_supp","RaceRelations_Better")]
#
```


<br>


### IV - Marital Status

```{r Marital Status, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Married
#CBS.2016$MARR
CBS.2016.final$MARR
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("MARR")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("MARR")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$MARR, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CBS.2016.final$MARR, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CBS.2016.final$MARR, useNA = "ifany")),2) # Checking %s with 2 ecimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$MaritalStatus <- CBS.2016.final$MARR
#
#5. Selecting options that have data 
#
# NA
CBS.2016.final[CBS.2016.final$MaritalStatus %in% c(2,3,4,9), "MaritalStatus"] <- NA
#
# Never Married
CBS.2016.final[CBS.2016.final$MaritalStatus %in% c(5), "MaritalStatus"] <- 0
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.maritalstatus <- CBS.2016.final[, c("BLM_supp","MaritalStatus")]
#
```


<br>


### IV - Race - Blacks

```{r Race - Blacks, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Blacks
#CBS.2016$RACEETH
CBS.2016.final$RACEETH

#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("RACEETH")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("RACEETH")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$RACEETH, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CBS.2016.final$RACEETH, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CBS.2016.final$RACEETH, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$Race_Blacks <- CBS.2016.final$RACEETH
#
#5. Selecting options that have data 
#
# NA
CBS.2016.final[CBS.2016.final$Race_Blacks %in% c(4,9), "Race_Blacks"] <- NA
#
# Other races
CBS.2016.final[CBS.2016.final$Race_Blacks %in% c(1,3), "Race_Blacks"] <- 0
#
#Blacks
CBS.2016.final[CBS.2016.final$Race_Blacks %in% c(2), "Race_Blacks"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.raceblacks <- CBS.2016.final[, c("BLM_supp","Race_Blacks")]
#
```


<br>




### IV - Race - Whites

```{r Race - Whites, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Whites
#CBS.2016$RACEETH
CBS.2016.final$RACEETH

#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("RACEETH")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("RACEETH")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$RACEETH, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CBS.2016.final$RACEETH, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CBS.2016.final$RACEETH, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$Race_Whites <- CBS.2016.final$RACEETH
#
#5. Selecting options that have data 
#
# NA
CBS.2016.final[CBS.2016.final$Race_Whites %in% c(4,9), "Race_Whites"] <- NA
#
# Other races
CBS.2016.final[CBS.2016.final$Race_Whites %in% c(2,3), "Race_Whites"] <- 0
#
#Whites
#CBS.2016.final[CBS.2016.final$Race_Whites %in% c(1), "Race_Whites"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.racewhites <- CBS.2016.final[, c("BLM_supp","Race_Whites")]
#
```


<br>





### IV - Race - Hispanic

```{r Race - Hispanic, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Hisp
#CBS.2016$RACEETH
CBS.2016.final$RACEETH

#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("RACEETH")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("RACEETH")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$RACEETH, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CBS.2016.final$RACEETH, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CBS.2016.final$RACEETH, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$Race_Hisp <- CBS.2016.final$RACEETH
#
#5. Selecting options that have data 
#
# NA
CBS.2016.final[CBS.2016.final$Race_Hisp %in% c(4,9), "Race_Hisp"] <- NA
#
# Other races
CBS.2016.final[CBS.2016.final$Race_Hisp %in% c(1,2), "Race_Hisp"] <- 0
#
#Hisp
CBS.2016.final[CBS.2016.final$Race_Hisp %in% c(3), "Race_Hisp"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.racehispanic <- CBS.2016.final[, c("BLM_supp","Race_Hisp")]
#
```


<br>


### IV - Personal Finances

```{r Personal Finances, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#confident with personal finances - Highest
#CBS.2016$PERSFINA
CBS.2016.final$PERSFINA
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("PERSFINA")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("PERSFINA")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$PERSFINA, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(CBS.2016.final$PERSFINA, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(CBS.2016.final$PERSFINA, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$Pers_Finances <- CBS.2016.final$PERSFINA
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$Pers_Finances %in% c(9), "Pers_Finances"] <- NA
#
#6. Recoding the IV (if necessary)
CBS.2016.final$Pers_Finances <- sapply(CBS.2016.final$Pers_Finances,  function(x) 5 - x)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.persfinances <- CBS.2016.final[, c("BLM_supp","Pers_Finances")]
#
```


<br>



### IV - Future of the country

```{r Future of the country, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CBS.2016$TRACK
CBS.2016.final$TRACK
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("TRACK")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("TRACK")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$TRACK, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CBS.2016.final$TRACK, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CBS.2016.final$TRACK, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$Country_Future <- CBS.2016.final$TRACK
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$Country_Future %in% c(9), "Country_Future"] <- NA
#
#6. Recoding the IV (if necessary)
CBS.2016.final$Country_Future <- sapply(CBS.2016.final$Country_Future,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.countryfuture <- CBS.2016.final[, c("BLM_supp","Country_Future")]
#

#Trying another variable
#CBS.2016.final$FUTGEN
#table(CBS.2016.final$FUTGEN, useNA = "ifany")
#CBS.2016.final$Country_Future <- CBS.2016.final$FUTGEN
#CBS.2016.final[CBS.2016.final$Country_Future %in% c(9), "Country_Future"] <- NA
#CBS.2016.final$Country_Future <- as.numeric(CBS.2016.final$Country_Future)
#CBS.2016.final$Country_Future <- car::recode(CBS.2016.final$Country_Future, ' "3"="2"; "2"="1"; "1"="3" ')
#CBS.2016.final.meta.countryfuture <- CBS.2016.final[, c("BLM_supp","Country_Future")]
```

### IV - Country Economy

```{r Country Economy, D5. CBS NewsNew York Times Poll 2016, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CBS.2016$TRACK
CBS.2016.final$RATEECON
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CBS.2016.final[,c("RATEECON")])   # Values check
sjlabelled::get_labels(CBS.2016.final[,c("RATEECON")])  # Values check
#
#3. Checking frequencies 
#
#table(CBS.2016.final$RATEECON, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CBS.2016.final$TRACK, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CBS.2016.final$TRACK, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CBS.2016.final$Country_Econ <- CBS.2016.final$RATEECON
#
#5. Selecting options that have data 
#
CBS.2016.final[CBS.2016.final$Country_Econ %in% c(9), "Country_Econ"] <- NA
#
#6. Recoding the IV (if necessary)
CBS.2016.final$Country_Econ <- sapply(CBS.2016.final$Country_Econ,  function(x) 5 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CBS.2016.final.meta.countryecon <- CBS.2016.final[, c("BLM_supp","Country_Econ")]
#

#Trying another question 
#CBS.2016.final$ECONDIRE
#table(CBS.2016.final$ECONDIRE, useNA = "ifany")
#CBS.2016.final$Country_Econ <- CBS.2016.final$ECONDIRE
#CBS.2016.final[CBS.2016.final$Country_Econ %in% c(9), "Country_Econ"] <- NA
#CBS.2016.final$Country_Econ <- as.numeric(CBS.2016.final$Country_Econ)
#CBS.2016.final$Country_Econ <- car::recode(CBS.2016.final$Country_Econ, ' "3"="2"; "2"="1"; "1"="3" ')
#CBS.2016.final.meta.countryecon <- CBS.2016.final[, c("BLM_supp","Country_Econ")]
```


<br>




## D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race
```{r loading data - D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}


######### PATH L.M. ####################
CNN.Kaiser <- haven::read_spss("Roper data/CNNKaiser Family Foundation Poll Survey of Americans on Race/uscnnkff2015-rae011.por")

######### PATH F.A. ####################
# CNN.Kaiser <- haven::read_spss("C:/Users/Flavio/Dropbox/Tamara/BLM/Roper data/CNNKaiser Family Foundation Poll Survey of Americans on Race/uscnnkff2015-rae011.por")

######### PATH T.M. ####################
#CNN.Kaiser <- haven::read_spss("C:/Users/tmmar/Dropbox/Tamara/BLM/Roper data/CNNKaiser Family Foundation Poll Survey of Americans on Race/uscnnkff2015-rae011.por")


labelled::look_for(CNN.Kaiser) %>% dplyr::as_tibble() -> CNN.Kaiser.codebook 

```

### DV

* D8c. (QND8C) Do you consider yourself to be a supporter of the Black Lives Matter movement, or not?
   - (1) Yes, supporter of the Black Lives Matter movement
   - (2) No, not a  supporter of the Black Lives Matter movement
   - (3) Haven't heard of it
   - (8) Don't know
   - (9) Refused
   

```{r DV, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}

CNN.Kaiser$QND8C
#
#2. Check the question and the labels 
sjlabelled::get_label(CNN.Kaiser[,c("QND8C")])   # Values check
sjlabelled::get_labels(CNN.Kaiser[,c("QND8C")])  # Values check
#
#3. Checking frequencies
table(CNN.Kaiser$QND8C, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.Kaiser$QND8C, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.Kaiser$QND8C, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating a new dataset to manipulate variables 
CNN.Kaiser.final <- CNN.Kaiser
#
#5. Creating Manipulated DV (BLM_supp) 
CNN.Kaiser.final$BLM_supp <- CNN.Kaiser.final$QND8C
#
#6. Selecting options that have data (= removing missing data)
#
CNN.Kaiser.final <- CNN.Kaiser.final[CNN.Kaiser.final$BLM_supp %in% c(1, 2),]
#
#7. Recoding the DV (if necessary)
#
CNN.Kaiser.final$BLM_supp <- sapply(CNN.Kaiser.final$BLM_supp,  function(x) 3 - x)


```

### IV - Income

```{r Income, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. checking the variable of interest
#
CNN.Kaiser.final$QND14
#
#2. Checking the question and the labels for the final dataset.. 
sjlabelled::get_label(CNN.Kaiser.final[,c("QND14")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("QND14")])  # Values check
#
#3. Checking frequencies 
#
table(CNN.Kaiser.final$QND14, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.Kaiser.final$QND14, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.Kaiser.final$QND14, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$HIncome <- CNN.Kaiser.final$QND14
#
#5. Selecting options that have data 
#
CNN.Kaiser.final[CNN.Kaiser.final$HIncome %in% c(98, 99), "HIncome"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#  
CNN.Kaiser.final.meta.income <- CNN.Kaiser.final[, c("BLM_supp","HIncome")]
#
```

### IV - Age

```{r Age, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#
CNN.Kaiser.final$AGE
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(CNN.Kaiser.final[,c("AGE")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("AGE")])  # Values check
#
#3. Checking frequencies 
#
table(CNN.Kaiser.final$AGE, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.Kaiser.final$AGE, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.Kaiser.final$AGE, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$RAge <- CNN.Kaiser.final$AGE
#
#5. Selecting options that have data 
#
CNN.Kaiser.final[CNN.Kaiser.final$RAge %in% c(9), "RAge"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
CNN.Kaiser.final.meta.age <- CNN.Kaiser.final[, c("BLM_supp","RAge")]
#
```


<br>

### IV - Gender

```{r Gender, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#
CNN.Kaiser.final$QNE
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(CNN.Kaiser.final[,c("QNE")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("QNE")])  # Values check
#
#3. Checking frequencies 
#
table(CNN.Kaiser.final$QNE, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.Kaiser.final$QNE, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.Kaiser.final$QNE, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$RGender <- CNN.Kaiser.final$QNE
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
CNN.Kaiser.final.meta.gender <- CNN.Kaiser.final[, c("BLM_supp","RGender")]
#
```


<br>



### IV - Education

```{r Education, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#
CNN.Kaiser.final$QND11
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(CNN.Kaiser.final[,c("QND11")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("QND11")])  # Values check
#
#3. Checking frequencies 
#
table(CNN.Kaiser.final$QND11, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.Kaiser.final$QND11, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.Kaiser.final$QND11, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$REducation <- CNN.Kaiser.final$QND11
#
#5. Selecting options that have data 
#
CNN.Kaiser.final[CNN.Kaiser.final$REducation %in% c(6,8,9), "REducation"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
CNN.Kaiser.final.meta.education <- CNN.Kaiser.final[, c("BLM_supp","REducation")]
#
```


<br>


### IV - Partisanship - Republicans

```{r Partisanship - Republicans, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Republican
CNN.Kaiser$QND8
CNN.Kaiser.final$QND8
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.Kaiser.final[,c("QND8")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("QND8")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.Kaiser.final$QND8, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.Kaiser.final$QND8, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.Kaiser.final$QND8, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$Partisanship_Rep <- CNN.Kaiser.final$QND8
#
#5. Selecting options that have data 
#
# NA
CNN.Kaiser.final[CNN.Kaiser.final$Partisanship_Rep %in% c(4,9), "Partisanship_Rep"] <- NA
#
#6. Recoding the IV (if necessary)
CNN.Kaiser.final$Partisanship_Rep <- as.numeric(CNN.Kaiser.final$Partisanship_Rep)
CNN.Kaiser.final$Partisanship_Rep <- car::recode(CNN.Kaiser.final$Partisanship_Rep, ' "1"="3";"2"="1"; "3"="2" ')
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.Kaiser.final.meta.partisanshiprep <- CNN.Kaiser.final[, c("BLM_supp","Partisanship_Rep")]
#
```


<br>



### IV - Ideology

```{r Ideology, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CNN.Kaiser$QND8B
CNN.Kaiser.final$QND8B
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.Kaiser.final[,c("QND8B")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("QND8B")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.Kaiser.final$QND8B, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.Kaiser.final$QND8B, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.Kaiser.final$QND8B, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$Ideol_Conservative <- CNN.Kaiser.final$QND8B
#
#5. Selecting options that have data 
#
CNN.Kaiser.final[CNN.Kaiser.final$Ideol_Conservative %in% c(8, 9), "Ideol_Conservative"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.Kaiser.final.meta.ideology <- CNN.Kaiser.final[, c("BLM_supp","Ideol_Conservative")]
#
```


<br>

### IV - RaceRelations - Better/Worse 

```{r Race Relations, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#Better- Highest
#CNN.Kaiser$QN10A
CNN.Kaiser.final$QN10A
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.Kaiser.final[,c("QN10A")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("QN10A")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.Kaiser.final$QN10A, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(CNN.Kaiser.final$QN10A, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(CNN.Kaiser.final$QN10A, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$RaceRelations_Better <- CNN.Kaiser.final$QN10A
#
#5. Selecting options that have data 
#
CNN.Kaiser.final[CNN.Kaiser.final$RaceRelations_Better %in% c(8,9), "RaceRelations_Better"] <- NA
#
#6. Recoding the IV (if necessary)
#CNN.Kaiser.final$RaceRelations <- sapply(CNN.Kaiser.final$RaceRelations,  function(x) 3 - x)

CNN.Kaiser.final$RaceRelations_Better <- as.numeric(CNN.Kaiser.final$RaceRelations_Better)
CNN.Kaiser.final$RaceRelations_Better <- car::recode(CNN.Kaiser.final$RaceRelations_Better, ' "2"="3"; "3"="2" ')

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.Kaiser.final.meta.racerelationsbetter <- CNN.Kaiser.final[, c("BLM_supp","RaceRelations_Better")]
#
```


<br>



### IV - Attended Racial Protests

```{r Attended Racial Protests, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#Attended Highest
#CNN.Kaiser$QND8D
CNN.Kaiser.final$QND8D
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.Kaiser.final[,c("QND8D")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("QND8D")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.Kaiser.final$QND8D, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(CNN.Kaiser.final$QND8D, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(CNN.Kaiser.final$QND8D, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$Attend_RacialProtest <- CNN.Kaiser.final$QND8D
#
#5. Selecting options that have data 
#
CNN.Kaiser.final[CNN.Kaiser.final$Attend_RacialProtest %in% c(9), "Attend_RacialProtest"] <- NA
#
#6. Recoding the IV (if necessary)
CNN.Kaiser.final$Attend_RacialProtest <- sapply(CNN.Kaiser.final$Attend_RacialProtest,  function(x) 3 - x)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.Kaiser.final.meta.attendracialprotest <- CNN.Kaiser.final[, c("BLM_supp","Attend_RacialProtest")]
#
```


<br>




### IV - Perceptions on racial discrimination (against Blacks)

```{r Perceptions on racial discrimination (against Blacks), D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest

CNN.Kaiser.final$QN7A
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.Kaiser.final[,c("QN7A")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("QN7A")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.Kaiser.final$QN7A, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(CNN.Kaiser.final$QN7A, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(CNN.Kaiser.final$QN7A, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$RacialDisc <- CNN.Kaiser.final$QN7A
#
#5. Selecting options that have data 
#
CNN.Kaiser.final[CNN.Kaiser.final$RacialDisc %in% c(8), "RacialDisc"] <- NA
#
#6. Recoding the IV (if necessary)
CNN.Kaiser.final$RacialDisc <- sapply(CNN.Kaiser.final$RacialDisc,  function(x) 5 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.Kaiser.final.meta.racialdisc <- CNN.Kaiser.final[, c("BLM_supp","RacialDisc")]
#
```


<br>



### IV - Personal experience with discrimination

```{r Personal discrimination, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#
CNN.Kaiser.final$QN20A
CNN.Kaiser.final$QN20B
CNN.Kaiser.final$QN20C
CNN.Kaiser.final$QN20D
CNN.Kaiser.final$QN20E
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.Kaiser.final[,c("QN20A")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("QN20A")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.Kaiser.final$QN20A, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.Kaiser.final$QN20A, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.Kaiser.final$QN20A, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$PersDiscr.A <- CNN.Kaiser.final$QN20A
CNN.Kaiser.final$PersDiscr.B <- CNN.Kaiser.final$QN20B
CNN.Kaiser.final$PersDiscr.C <- CNN.Kaiser.final$QN20C
CNN.Kaiser.final$PersDiscr.D <- CNN.Kaiser.final$QN20D
CNN.Kaiser.final$PersDiscr.E <- CNN.Kaiser.final$QN20E
#
#5. Selecting options that have data 
#
CNN.Kaiser.final[CNN.Kaiser.final$PersDiscr.A %in% c(8), "PersDiscr.A"] <- NA
CNN.Kaiser.final[CNN.Kaiser.final$PersDiscr.B %in% c(8, 9), "PersDiscr.B"] <- NA
CNN.Kaiser.final[CNN.Kaiser.final$PersDiscr.C %in% c(8, 9), "PersDiscr.C"] <- NA
CNN.Kaiser.final[CNN.Kaiser.final$PersDiscr.D %in% c(8, 9), "PersDiscr.D"] <- NA
CNN.Kaiser.final[CNN.Kaiser.final$PersDiscr.E %in% c(8, 9), "PersDiscr.E"] <- NA
#

#6. Recoding the IV (if necessary)
#
CNN.Kaiser.final$PersDiscr.A.rec <- CNN.Kaiser.final$PersDiscr.A
CNN.Kaiser.final$PersDiscr.A.rec <- sapply(CNN.Kaiser.final$PersDiscr.A.rec,  function(x) 3 - x)
#
CNN.Kaiser.final$PersDiscr.B.rec <- CNN.Kaiser.final$PersDiscr.B
CNN.Kaiser.final$PersDiscr.B.rec <- sapply(CNN.Kaiser.final$PersDiscr.B.rec,  function(x) 3 - x)
# 
CNN.Kaiser.final$PersDiscr.C.rec <- CNN.Kaiser.final$PersDiscr.C
CNN.Kaiser.final$PersDiscr.C.rec <- sapply(CNN.Kaiser.final$PersDiscr.C.rec,  function(x) 3 - x)
#
# 
CNN.Kaiser.final$PersDiscr.D.rec <- CNN.Kaiser.final$PersDiscr.D
CNN.Kaiser.final$PersDiscr.D.rec <- sapply(CNN.Kaiser.final$PersDiscr.D.rec,  function(x) 3 - x)
#
#
CNN.Kaiser.final$PersDiscr.E.rec <- CNN.Kaiser.final$PersDiscr.E
CNN.Kaiser.final$PersDiscr.E.rec <- sapply(CNN.Kaiser.final$PersDiscr.E.rec,  function(x) 3 - x)
#
#
# Averaging the variables
CNN.Kaiser.final$PersDiscr <- rowMeans(CNN.Kaiser.final[ , c("PersDiscr.A.rec", "PersDiscr.B.rec", "PersDiscr.C.rec", "PersDiscr.D.rec", "PersDiscr.E.rec")], na.rm=TRUE)
#?rowMeans
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.Kaiser.final.meta.persdiscr <- CNN.Kaiser.final[, c("BLM_supp","PersDiscr")]
#
```




### IV - Marital Status

```{r Marital Status, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Married
#CNN.Kaiser$QND5
CNN.Kaiser.final$QND5
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.Kaiser.final[,c("QND5")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("QND5")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.Kaiser.final$QND5, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.Kaiser.final$QND5, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.Kaiser.final$QND5, useNA = "ifany")),2) # Checking %s with 2 decimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$MaritalStatus <- CNN.Kaiser.final$QND5
#
#5. Selecting options that have data 
#
# NA
CNN.Kaiser.final[CNN.Kaiser.final$MaritalStatus %in% c(2,4,5,6,9), "MaritalStatus"] <- NA
#
# Single
CNN.Kaiser.final[CNN.Kaiser.final$MaritalStatus %in% c(1), "MaritalStatus"] <- 0
#
# Married
CNN.Kaiser.final[CNN.Kaiser.final$MaritalStatus %in% c(3), "MaritalStatus"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.Kaiser.final.meta.maritalstatus <- CNN.Kaiser.final[, c("BLM_supp","MaritalStatus")]
#
```


<br>



### IV - Employment Status

```{r Employment Status, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Married
#CNN.Kaiser$QN4
#CNN.Kaiser.final$QN4
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.Kaiser.final[,c("QN4")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("QN4")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.Kaiser.final$QN4, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.Kaiser.final$QN4, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.Kaiser.final$QN4, useNA = "ifany")),2) # Checking %s with 2 decimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$EmploymentStatus <- CNN.Kaiser.final$QN4
#
#
#5. Selecting options that have data 
#
# NA
CNN.Kaiser.final[CNN.Kaiser.final$EmploymentStatus %in% c(3,4,5,7,8,98,99), "EmploymentStatus"] <- NA
#
# Working
CNN.Kaiser.final[CNN.Kaiser.final$EmploymentStatus %in% c(1,2), "EmploymentStatus"] <- 1
#
# Retired
CNN.Kaiser.final[CNN.Kaiser.final$EmploymentStatus %in% c(6), "EmploymentStatus"] <- 0
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.Kaiser.final.meta.employmentstatus <- CNN.Kaiser.final[, c("BLM_supp","EmploymentStatus")]
#
```


<br>



### IV - Race - Blacks

```{r Race - Blacks, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Blacks
CNN.Kaiser.final$RACEVAR
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.Kaiser.final[,c("RACEVAR")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("RACEVAR")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.Kaiser.final$RACEVAR, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.Kaiser.final$RACEVAR, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.Kaiser.final$RACEVAR, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$Race_Blacks <- CNN.Kaiser.final$RACEVAR
#
#5. Selecting options that have data 
#
# NA
CNN.Kaiser.final[CNN.Kaiser.final$Race_Blacks %in% c(4, 6, 7), "Race_Blacks"] <- NA
#
# Other races
CNN.Kaiser.final[CNN.Kaiser.final$Race_Blacks %in% c(1,2,5), "Race_Blacks"] <- 0
#
#Blacks
CNN.Kaiser.final[CNN.Kaiser.final$Race_Blacks %in% c(3), "Race_Blacks"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.Kaiser.final.meta.raceblacks <- CNN.Kaiser.final[, c("BLM_supp","Race_Blacks")]
#
```


<br>



### IV - Race - Whites

```{r Race - Whites, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Whites
#CNN.Kaiser$RACEVAR
CNN.Kaiser.final$RACEVAR
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.Kaiser.final[,c("RACEVAR")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("RACEVAR")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.Kaiser.final$RACEVAR, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.Kaiser.final$RACEVAR, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.Kaiser.final$RACEVAR, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$Race_Whites <- CNN.Kaiser.final$RACEVAR
#
#5. Selecting options that have data 
#
# NA
CNN.Kaiser.final[CNN.Kaiser.final$Race_Whites %in% c(4, 6, 7), "Race_Whites"] <- NA
#
# Other races
CNN.Kaiser.final[CNN.Kaiser.final$Race_Whites %in% c(1,3,5), "Race_Whites"] <- 0
#
#Whites
CNN.Kaiser.final[CNN.Kaiser.final$Race_Whites %in% c(2), "Race_Whites"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.Kaiser.final.meta.racewhites <- CNN.Kaiser.final[, c("BLM_supp","Race_Whites")]
#
```


<br>


### IV - Race - Hispanic

```{r Race - Hispanic, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Hisp
#CNN.Kaiser$RACEVAR
CNN.Kaiser.final$RACEVAR
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.Kaiser.final[,c("RACEVAR")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("RACEVAR")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.Kaiser.final$RACEVAR, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.Kaiser.final$RACEVAR, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.Kaiser.final$RACEVAR, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$Race_Hisp <- CNN.Kaiser.final$RACEVAR
#
#5. Selecting options that have data 
#
# NA
CNN.Kaiser.final[CNN.Kaiser.final$Race_Hisp %in% c(4, 6, 7), "Race_Hisp"] <- NA
#
# Other races
CNN.Kaiser.final[CNN.Kaiser.final$Race_Hisp %in% c(2,3,5), "Race_Hisp"] <- 0
#
#Hisp
#CNN.Kaiser.final[CNN.Kaiser.final$Race_Hisp %in% c1, "Race_Hisp"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.Kaiser.final.meta.racehispanic <- CNN.Kaiser.final[, c("BLM_supp","Race_Hisp")]
#
```


<br>



### IV - Race - Asians

```{r Race - Asians, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Asians
#CNN.Kaiser$RACEVAR
CNN.Kaiser.final$RACEVAR
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.Kaiser.final[,c("RACEVAR")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("RACEVAR")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.Kaiser.final$RACEVAR, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.Kaiser.final$RACEVAR, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.Kaiser.final$RACEVAR, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$Race_Asians <- CNN.Kaiser.final$RACEVAR
#
#5. Selecting options that have data 
#
# NA
CNN.Kaiser.final[CNN.Kaiser.final$Race_Asians %in% c(4, 6, 7), "Race_Asians"] <- NA
#
# Other races
CNN.Kaiser.final[CNN.Kaiser.final$Race_Asians %in% c(1,2,3), "Race_Asians"] <- 0
#
#Asians
CNN.Kaiser.final[CNN.Kaiser.final$Race_Asians %in% c(5), "Race_Asians"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.Kaiser.final.meta.raceasians <- CNN.Kaiser.final[, c("BLM_supp","Race_Asians")]
#
```


<br>



### IV - Systematic Racism

```{r Systematic Racism, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CNN.Kaiser.final$QN17
#CNN.Kaiser.final$QN17
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(CNN.Kaiser.final[,c("QN17")])   # Values check
#sjlabelled::get_labels(CNN.Kaiser.final[,c("QN17")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.Kaiser.final$QN17, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(CNN.Kaiser.final$QN17, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(CNN.Kaiser.final$QN17, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
#CNN.Kaiser.final$SystematicRacism <- CNN.Kaiser.final$QN17
#
#5. Selecting options that have data 
#
#CNN.Kaiser.final[CNN.Kaiser.final$SystematicRacism %in% c(8, 9), "SystematicRacism"] <- NA
#
#6. Recoding the IV (if necessary)
#CNN.Kaiser.final$SystematicRacism <- sapply(CNN.Kaiser.final$SystematicRacism,  function(x) 3 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
#CNN.Kaiser.final.meta.systematicracism <- CNN.Kaiser.final[, c("BLM_supp","SystematicRacism")]
#

##### Trying another variable
CNN.Kaiser.final$QN9AB
table(CNN.Kaiser.final$QN9AB, useNA = "ifany")
CNN.Kaiser.final$SystematicRacism <- CNN.Kaiser.final$QN9AB
CNN.Kaiser.final[CNN.Kaiser.final$SystematicRacism %in% c(8), "SystematicRacism"] <- NA
CNN.Kaiser.final$SystematicRacism <- sapply(CNN.Kaiser.final$SystematicRacism,  function(x) 4 - x)
CNN.Kaiser.final.meta.systematicracism <- CNN.Kaiser.final[, c("BLM_supp","SystematicRacism")]
```


<br>



### IV - Personal Finances

```{r Personal Finances, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#confident with personal finances - Highest
#CNN.Kaiser$QN3
CNN.Kaiser.final$QN3
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.Kaiser.final[,c("QN3")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("QN3")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.Kaiser.final$QN3, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(CNN.Kaiser.final$QN3, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(CNN.Kaiser.final$QN3, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$Pers_Finances <- CNN.Kaiser.final$QN3
#
#5. Selecting options that have data 
#
CNN.Kaiser.final[CNN.Kaiser.final$Pers_Finances %in% c(8, 9), "Pers_Finances"] <- NA
#
#6. Recoding the IV (if necessary)
CNN.Kaiser.final$Pers_Finances <- sapply(CNN.Kaiser.final$Pers_Finances,  function(x) 5 - x)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.Kaiser.final.meta.persfinances <- CNN.Kaiser.final[, c("BLM_supp","Pers_Finances")]
#
```

### IV - Protests Legitimate

```{r Protest Legitimate, D6. CNN Kaiser Family Foundation Poll Survey of Americans on Race, include=FALSE}
# 1. Instructions to check the variable of interest
#confident with personal finances - Highest
#CNN.Kaiser$QN3
CNN.Kaiser.final$QN16BC
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.Kaiser.final[,c("QN16BC")])   # Values check
sjlabelled::get_labels(CNN.Kaiser.final[,c("QN16BC")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.Kaiser.final$QN16BC, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(CNN.Kaiser.final$QN16BC, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(CNN.Kaiser.final$QN16BC, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.Kaiser.final$Protest_Legit <- CNN.Kaiser.final$QN16BC
#
#5. Selecting options that have data 
#
CNN.Kaiser.final[CNN.Kaiser.final$Protest_Legit %in% c(8, 9), "Protest_Legit"] <- NA
#
#6. Recoding the IV (if necessary)
CNN.Kaiser.final$Protest_Legit <- sapply(CNN.Kaiser.final$Protest_Legit,  function(x) 4 - x)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.Kaiser.final.meta.protestlegit <- CNN.Kaiser.final[, c("BLM_supp","Protest_Legit")]
#
# TRying new variable
#CNN.Kaiser.final$QN16BB
#table(CNN.Kaiser.final$QN16BB, useNA = "ifany")
#CNN.Kaiser.final$Protest_Legit <- CNN.Kaiser.final$QN16BB
#CNN.Kaiser.final[CNN.Kaiser.final$Protest_Legit %in% c(8, 9), "Protest_Legit"] <- NA
#CNN.Kaiser.final$Protest_Legit <- sapply(CNN.Kaiser.final$Protest_Legit,  function(x) 4 - x)
#CNN.Kaiser.final.meta.protestlegit <- CNN.Kaiser.final[, c("BLM_supp","Protest_Legit")]
```



<br>




## D7. CNN NORC Poll 2016 Presidential Debates

```{r loading data - D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}

######### PATH L.M. ####################
CNN.NORC <- haven::read_spss("Roper data/CNNORC Poll 2016 Presidential DebatesTrumps TaxesRacial DiscriminationProtests/usorccnn2016-1002.por")

######### PATH F.A. ####################
# CNN.NORC <- haven::read_spss("C:/Users/Flavio/Dropbox/Tamara/BLM/Roper data/CNNORC Poll 2016 Presidential DebatesTrumps TaxesRacial DiscriminationProtests/usorccnn2016-1002.por")

######### PATH T.M. ####################
#CNN.NORC <- haven::read_spss("C:/Users/tmmar/Dropbox/Tamara/BLM/Roper data/CNNORC Poll 2016 Presidential DebatesTrumps TaxesRacial DiscriminationProtests/usorccnn2016-1002.por")


labelled::look_for(CNN.NORC) %>% dplyr::as_tibble() -> CNN.NORC.codebook 

```

### DV

* FV1BLM. We’d like to get your overall opinion of some people in the news. As I read each name, please say if you have
a favorable or unfavorable opinion of these people -- or if you have never heard of them. [BLM. The Black Lives Matter Movement]
   - (1) Favorable
   - (2) Unfavorable
   - (3) Heard of/no opinion 
   - (4) Never heard of it
   - (9) Don't know/Undecided/Refused

```{r DV, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}

CNN.NORC$FV1BLM
#
#2. Check the question and the labels 
sjlabelled::get_label(CNN.NORC[,c("FV1BLM")])   # Values check
sjlabelled::get_labels(CNN.NORC[,c("FV1BLM")])  # Values check
#
#3. Checking frequencies
table(CNN.NORC$FV1BLM, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.NORC$FV1BLM, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.NORC$FV1BLM, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating a new dataset to manipulate variables 
CNN.NORC.final <- CNN.NORC
#
#5. Creating Manipulated DV (BLM_supp) 
CNN.NORC.final$BLM_supp <- CNN.NORC.final$FV1BLM
#
#6. Selecting options that have data (= removing missing data)
#
CNN.NORC.final <- CNN.NORC.final[CNN.NORC.final$BLM_supp %in% c(1, 2),]
#
#7. Recoding the DV (if necessary)
#
CNN.NORC.final$BLM_supp <- sapply(CNN.NORC.final$BLM_supp,  function(x) 3 - x)


```

### IV - Income

```{r Income, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. checking the variable of interest
#
CNN.NORC.final$INCOME
#
#2. Checking the question and the labels for the final dataset.. 
sjlabelled::get_label(CNN.NORC.final[,c("INCOME")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("INCOME")])  # Values check
#
#3. Checking frequencies 
#
table(CNN.NORC.final$INCOME, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.NORC.final$INCOME, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.NORC.final$INCOME, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$HIncome <- CNN.NORC.final$INCOME
#
#5. Selecting options that have data 
#
CNN.NORC.final[CNN.NORC.final$HIncome %in% c(9), "HIncome"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
CNN.NORC.final.meta.income <- CNN.NORC.final[, c("BLM_supp","HIncome")]
#
```

### IV - Age

```{r Age, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
CNN.NORC.final$AGE
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(CNN.NORC.final[,c("AGE")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("AGE")])  # Values check
#
#3. Checking frequencies 
#
table(CNN.NORC.final$AGE, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.NORC.final$AGE, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.NORC.final$INCOME, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$RAge <- CNN.NORC.final$AGE
#
#5. Selecting options that have data 
#
CNN.NORC.final[CNN.NORC.final$RAge %in% c(9), "RAge"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
CNN.NORC.final.meta.age <- CNN.NORC.final[, c("BLM_supp","RAge")]
#
```

<br>


### IV - Gender

```{r Gender, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
CNN.NORC.final$SEX
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(CNN.NORC.final[,c("SEX")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("SEX")])  # Values check
#
#3. Checking frequencies 
#
table(CNN.NORC.final$SEX, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.NORC.final$SEX, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.NORC.final$SEX, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$RGender <- CNN.NORC.final$SEX
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
CNN.NORC.final.meta.gender <- CNN.NORC.final[, c("BLM_supp","RGender")]
#
```

<br>



### IV - Education

```{r Education, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
CNN.NORC.final$EEDUC
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.final[,c("EDUC")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("EDUC")])  # Values check
#
#3. Checking frequencies 
#
table(CNN.NORC.final$EEDUC, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.NORC.final$EEDUC, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.NORC.final$EEDUC, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$REducation <- CNN.NORC.final$EEDUC
#
#5. Selecting options that have data 
#
CNN.NORC.final[CNN.NORC.final$REducation %in% c(9), "REducation"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.final.meta.education <- CNN.NORC.final[, c("BLM_supp","REducation")]
#
```

### IV - Urbanicity

```{r Urbanicity, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
CNN.NORC.final$URBAN
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(CNN.NORC.final[,c("URBAN")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("URBAN")])  # Values check
#
#3. Checking frequencies 
#
table(CNN.NORC.final$URBAN, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.NORC.final$URBAN, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.NORC.final$URBAN, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$Urbanicity <- CNN.NORC.final$URBAN
#
#5. Selecting options that have data 
CNN.NORC.final[CNN.NORC.final$Urbanicity %in% c(99), "Urbanicity"] <- NA
#
#RECODING
CNN.NORC.final$Urbanicity <- sapply(CNN.NORC.final$Urbanicity,  function(x) 4 - x)
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
CNN.NORC.final.meta.urbanicity <- CNN.NORC.final[, c("BLM_supp","Urbanicity")]
#
```

<br>


### IV - Partisanship - Republicans

```{r Partisanship - Republicans, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Republican
#CNN.NORC$PARTY1
CNN.NORC.final$PARTY1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.final[,c("PARTY1")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("PARTY1")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.final$PARTY1, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.final$PARTY1, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.final$PARTY1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$Partisanship_Rep <- CNN.NORC.final$PARTY1
#
#5. Selecting options that have data 
#
# NA
CNN.NORC.final[CNN.NORC.final$Partisanship_Rep %in% c(4,9), "Partisanship_Rep"] <- NA
#
#
#6. Recoding the IV (if necessary)
CNN.NORC.final$Partisanship_Rep <- as.numeric(CNN.NORC.final$Partisanship_Rep)
CNN.NORC.final$Partisanship_Rep <- car::recode(CNN.NORC.final$Partisanship_Rep, ' "1"="3";"2"="1"; "3"="2" ')
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.final.meta.partisanshiprep <- CNN.NORC.final[, c("BLM_supp","Partisanship_Rep")]
#
```


<br>



### IV - Ideology

```{r Ideology, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CNN.NORC$IDEOLOGY
CNN.NORC.final$IDEOLOGY
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.final[,c("IDEOLOGY")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("IDEOLOGY")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.final$IDEOLOGY, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.final$IDEOLOGY, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.final$IDEOLOGY, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$Ideol_Conservative <- CNN.NORC.final$IDEOLOGY
#
#5. Selecting options that have data 
#
CNN.NORC.final[CNN.NORC.final$Ideol_Conservative %in% c(0), "Ideol_Conservative"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.final.meta.ideology <- CNN.NORC.final[, c("BLM_supp","Ideol_Conservative")]
#
```


<br>




### IV - Religiosity

```{r Religiosity, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CNN.NORC$RELIGION
CNN.NORC.final$RELIGION
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.final[,c("RELIGION")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("RELIGION")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.final$RELIGION, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.final$RELIGION, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.final$RELIGION, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$Religiosity <- CNN.NORC.final$RELIGION
#
#5. Selecting options that have data 
#
CNN.NORC.final[CNN.NORC.final$Religiosity %in% c(1,2,3,4), "Religiosity"] <- 1
CNN.NORC.final[CNN.NORC.final$Religiosity %in% c(5), "Religiosity"] <- 0
CNN.NORC.final[CNN.NORC.final$Religiosity %in% c(9), "Religiosity"] <- NA
#
#6. Recoding the IV (if necessary)
#CNN.NORC.final$Religiosity <- sapply(CNN.NORC.final$Religiosity,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.final.meta.religiosity <- CNN.NORC.final[, c("BLM_supp","Religiosity")]
#
```


<br>



### IV - Police Misconduct

```{r Police Misconduct, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
CNN.NORC$Q21
CNN.NORC.final$Q21
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.final[,c("Q21")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("Q21")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.final$Q21, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.final$Q21, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.final$Q21, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$PoliceMisc <- CNN.NORC.final$Q21
#
#5. Selecting options that have data 
#
CNN.NORC.final[CNN.NORC.final$PoliceMisc %in% c(9), "PoliceMisc"] <- NA
#
#6. Recoding the IV (if necessary)
CNN.NORC.final$PoliceMisc <- as.numeric(CNN.NORC.final$PoliceMisc)
CNN.NORC.final$PoliceMisc <- car::recode(CNN.NORC.final$PoliceMisc, ' "1"="5"; "2"="4"; "3"="3"; "4"="2"; "5"="6"; "6"="1" ')
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.final.meta.policemisconduct <- CNN.NORC.final[, c("BLM_supp","PoliceMisc")]
#
```


<br>




### IV - Registered to Vote

```{r Registered to Vote, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CNN.NORC$REGISTER
CNN.NORC.final$REGISTER
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.final[,c("REGISTER")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("REGISTER")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.final$REGISTER, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.final$REGISTER, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.final$REGISTER, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$VoteReg <- CNN.NORC.final$REGISTER
#
#5. Selecting options that have data 
#
CNN.NORC.final[CNN.NORC.final$VoteReg %in% c(3), "VoteReg"] <- NA
#
#6. Recoding the IV (if necessary)
CNN.NORC.final$VoteReg <- sapply(CNN.NORC.final$VoteReg,  function(x) 3 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.final.meta.votereg <- CNN.NORC.final[, c("BLM_supp","VoteReg")]
#
```


<br>


### IV - Obama Approval

```{r Obama Approval, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Obama Approval
#CNN.NORC$APPROVAL
CNN.NORC.final$APPROVAL
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.final[,c("APPROVAL")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("APPROVAL")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.final$APPROVAL, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.final$APPROVAL, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.final$APPROVAL, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$Obama_App <- CNN.NORC.final$APPROVAL
#
#5. Selecting options that have data 
#
CNN.NORC.final[CNN.NORC.final$Obama_App %in% c(9), "Obama_App"] <- NA
#
#6. Recoding the IV (if necessary)
CNN.NORC.final$Obama_App <- sapply(CNN.NORC.final$Obama_App,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.final.meta.obamaapp <- CNN.NORC.final[, c("BLM_supp","Obama_App")]
#
```


<br>



### IV - Hillary - Favorability

```{r Hillary - Favorability, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
# Favorability towards Hillary Clinton
#CNN.NORC$FV1HRC
CNN.NORC.final$FV1HRC
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.final[,c("FV1HRC")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("FV1HRC")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.final$FV1HRC, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.final$FV1HRC, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.final$FV1HRC, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$Hillary_Fav <- CNN.NORC.final$FV1HRC
#
#5. Selecting options that have data 
#
CNN.NORC.final[CNN.NORC.final$Hillary_Fav %in% c(3,9), "Hillary_Fav"] <- NA
#
#6. Recoding the IV (if necessary)
CNN.NORC.final$Hillary_Fav <- sapply(CNN.NORC.final$Hillary_Fav,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.final.meta.hillaryfav <- CNN.NORC.final[, c("BLM_supp","Hillary_Fav")]
#
```


<br>



### IV - Trump - Favorability

```{r Trump - Favorability, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
# Favorability towards trump Clinton
#CNN.NORC$FV1DJT
CNN.NORC.final$FV1DJT
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.final[,c("FV1DJT")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("FV1DJT")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.final$FV1DJT, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.final$FV1DJT, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.final$FV1DJT, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$Trump_Fav <- CNN.NORC.final$FV1DJT
#
#5. Selecting options that have data 
#
CNN.NORC.final[CNN.NORC.final$Trump_Fav %in% c(3,9), "Trump_Fav"] <- NA
#
#6. Recoding the IV (if necessary)
CNN.NORC.final$Trump_Fav <- sapply(CNN.NORC.final$Trump_Fav,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.final.meta.trumpfav <- CNN.NORC.final[, c("BLM_supp","Trump_Fav")]
#
```


<br>


### IV - Vote 2016 - Clinton VS Trump

```{r Vote 2016 - Clinton VS Trump, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
# Favorability towards Trump
#CNN.NORC$P5
CNN.NORC.final$P5
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.final[,c("P5")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("P5")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.final$P5, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.final$P5, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.final$P5, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$Vote16_ClintonVSTrump <- CNN.NORC.final$P5
#
#5. Selecting options that have data 
#
CNN.NORC.final[CNN.NORC.final$Vote16_ClintonVSTrump %in% c(3,4,6,7,9), "Vote16_ClintonVSTrump"] <- NA
#
#6. Recoding the IV (if necessary)
#
#CNN.NORC.final$Vote16_ClintonVSTrump <- sapply(CNN.NORC.final$Vote16_ClintonVSTrump,  function(x) 3 - x)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.final.meta.vote16clintonvstrump <- CNN.NORC.final[, c("BLM_supp","Vote16_ClintonVSTrump")]
#
```


<br>


### IV - Perceptions on racial discrimination (against Blacks)

```{r Perceptions on racial discrimination (against Blacks), D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#Very serious Highest
CNN.NORC.final$Q18
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.final[,c("Q18")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("Q18")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.final$Q18, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(CNN.NORC.final$Q18, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(CNN.NORC.final$Q18, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$RacialDisc <- CNN.NORC.final$Q18
#
#5. Selecting options that have data 
#
CNN.NORC.final[CNN.NORC.final$RacialDisc %in% c(9), "RacialDisc"] <- NA
#
#6. Recoding the IV (if necessary)
CNN.NORC.final$RacialDisc <- sapply(CNN.NORC.final$RacialDisc,  function(x) 5 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.final.meta.racialdisc <- CNN.NORC.final[, c("BLM_supp","RacialDisc")]
#
```


<br>


### IV - Marital Status

```{r Marital Status, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Married
#CNN.NORC$MARITAL
CNN.NORC.final$MARITAL
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.final[,c("MARITAL")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("MARITAL")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.final$MARITAL, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.final$MARITAL, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.final$MARITAL, useNA = "ifany")),2) # Checking %s with 2 ecimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$MaritalStatus <- CNN.NORC.final$MARITAL
#
#5. Selecting options that have data 
#
# NA
CNN.NORC.final[CNN.NORC.final$MaritalStatus %in% c(2,4,5,6,9), "MaritalStatus"] <- NA
#
# Single
CNN.NORC.final[CNN.NORC.final$MaritalStatus %in% c(3), "MaritalStatus"] <- 0
#
#

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.final.meta.maritalstatus <- CNN.NORC.final[, c("BLM_supp","MaritalStatus")]
#
```


<br>


### IV - Race - Blacks

```{r Race - Blacks, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CNN.NORC$RACE1
CNN.NORC.final$RACE1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.final[,c("RACE1")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("RACE1")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.final$RACE1, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.final$RACE1, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.final$RACE1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$Race_Blacks <- CNN.NORC.final$RACE1
#
CNN.NORC.final[CNN.NORC.final$HISPANIC %in% c('1'),"Race_Blacks"] <- 3
#table(CNN.NORC.final$Race, useNA = "ifany")   

#5. Selecting options that have data 
#
# Check frequencies of hispanics across race categories
#ftable(RACE1 ~ HISPANIC, data = CNN.NORC.final)
# NA
CNN.NORC.final[CNN.NORC.final$Race_Blacks %in% c(5,9), "Race_Blacks"] <- NA
#
# Other races
CNN.NORC.final[CNN.NORC.final$Race_Blacks %in% c(1,3,4), "Race_Blacks"] <- 0
#
# Other races
CNN.NORC.final[CNN.NORC.final$Race_Blacks %in% c(2), "Race_Blacks"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.final.meta.raceblacks <- CNN.NORC.final[, c("BLM_supp","Race_Blacks")]
#
```


<br>


### IV - Race - Whites

```{r Race - Whites, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CNN.NORC$RACE1
CNN.NORC.final$RACE1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.final[,c("RACE1")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("RACE1")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.final$RACE1, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.final$RACE1, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.final$RACE1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$Race_Whites <- CNN.NORC.final$RACE1
#
CNN.NORC.final[CNN.NORC.final$HISPANIC %in% c('1'),"Race_Whites"] <- 3
#table(CNN.NORC.final$Race, useNA = "ifany")   

#5. Selecting options that have data 
#
# Check frequencies of hispanics across race categories
#ftable(RACE1 ~ HISPANIC, data = CNN.NORC.final)
# NA
CNN.NORC.final[CNN.NORC.final$Race_Whites %in% c(5,9), "Race_Whites"] <- NA
#
# Other races
CNN.NORC.final[CNN.NORC.final$Race_Whites %in% c(2,3,4), "Race_Whites"] <- 0
#

#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.final.meta.racewhites <- CNN.NORC.final[, c("BLM_supp","Race_Whites")]
#
```


<br>



### IV - Race - Hispanic

```{r Race - Hispanic, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CNN.NORC$RACE1
CNN.NORC.final$RACE1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.final[,c("RACE1")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("RACE1")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.final$RACE1, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.final$RACE1, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.final$RACE1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$Race_Hisp <- CNN.NORC.final$RACE1
#
CNN.NORC.final[CNN.NORC.final$HISPANIC %in% c('1'),"Race_Hisp"] <- 3
#table(CNN.NORC.final$Race, useNA = "ifany")   

#5. Selecting options that have data 
#
# Check frequencies of hispanics across race categories
#ftable(RACE1 ~ HISPANIC, data = CNN.NORC.final)
# NA
CNN.NORC.final[CNN.NORC.final$Race_Hisp %in% c(5,9), "Race_Hisp"] <- NA
#
# Other races
CNN.NORC.final[CNN.NORC.final$Race_Hisp %in% c(1,2,4), "Race_Hisp"] <- 0
#
# Other races
CNN.NORC.final[CNN.NORC.final$Race_Hisp %in% c(3), "Race_Hisp"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.final.meta.racehispanic <- CNN.NORC.final[, c("BLM_supp","Race_Hisp")]
#
```


<br>

### IV - Race - Asians

```{r Race - Asians, D7. CNN NORC Poll 2016 Presidential Debates, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CNN.NORC$RACE1
CNN.NORC.final$RACE1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.final[,c("RACE1")])   # Values check
sjlabelled::get_labels(CNN.NORC.final[,c("RACE1")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.final$RACE1, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.final$RACE1, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.final$RACE1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.final$Race_Asians <- CNN.NORC.final$RACE1
#
CNN.NORC.final[CNN.NORC.final$HISPANIC %in% c('1'),"Race_Asians"] <- 3
#table(CNN.NORC.final$Race, useNA = "ifany")   

#5. Selecting options that have data 
#
# Check frequencies of hispanics across race categories
#ftable(RACE1 ~ HISPANIC, data = CNN.NORC.final)
# NA
CNN.NORC.final[CNN.NORC.final$Race_Asians %in% c(5,9), "Race_Asians"] <- NA
#
# Other races
CNN.NORC.final[CNN.NORC.final$Race_Asians %in% c(1,2,3), "Race_Asians"] <- 0
#
# Other races
CNN.NORC.final[CNN.NORC.final$Race_Asians %in% c(4), "Race_Asians"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.final.meta.raceasians <- CNN.NORC.final[, c("BLM_supp","Race_Asians")]
#
```


<br>



## D8. CNN NORC Poll 2016 Presidential Elections

```{r loading data - D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}

######### PATH L.M. ####################
CNN.NORC.Elections <- haven::read_spss("Roper data/CNNORC Poll 2016 Presidential Election Barack Obama Presidency Combat Operations Against ISIS 10-Year Review of Hurricane Katrina/usorccnn2015-008.por")

######### PATH F.A. ####################
# CNN.NORC.Elections <- haven::read_spss("C:/Users/Flavio/Dropbox/Tamara/BLM/Roper data/CNNORC Poll 2016 Presidential Election Barack Obama Presidency Combat Operations Against ISIS 10-Year Review of Hurricane Katrina/usorccnn2015-008.por")

######### PATH T.M. ####################
#CNN.NORC.Elections <- haven::read_spss("C:/Users/tmmar/Dropbox/Tamara/BLM/Roper data/CNNORC Poll 2016 Presidential Election Barack Obama Presidency Combat Operations Against ISIS 10-Year Review of Hurricane Katrina/usorccnn2015-008.por")


labelled::look_for(CNN.NORC.Elections) %>% dplyr::as_tibble() -> CNN.NORC.Elections.codebook 

```

### DV

* FV1BLM. We’d like to get your overall opinion of some people in the news. As I read each name, please say if you have a favorable or unfavorable opinion of these people -- or if you have never heard of them. [BLM. The Black Lives Matter Movement]
   - (1) Favorable
   - (2) Unfavorable
   - (3) Heard of/no opinion 
   - (4) Never heard of it
   - (9) Don't know/Undecided/Refused
 
```{r DV, D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}

CNN.NORC.Elections$Q10K
#
#2. Check the question and the labels 
sjlabelled::get_label(CNN.NORC.Elections[,c("Q10K")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections[,c("Q10K")])  # Values check
#
#3. Checking frequencies
table(CNN.NORC.Elections$Q10K, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.NORC.Elections$Q10K, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.NORC.Elections$Q10K, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating a new dataset to manipulate variables 
CNN.NORC.Elections.final <- CNN.NORC.Elections
#
#5. Creating Manipulated DV (BLM_supp) 
CNN.NORC.Elections.final$BLM_supp <- CNN.NORC.Elections.final$Q10K
#
#6. Selecting options that have data (= removing missing data)
#
CNN.NORC.Elections.final <- CNN.NORC.Elections.final[CNN.NORC.Elections.final$BLM_supp %in% c(1, 2),]
#
#7. Recoding the DV (if necessary)
#
CNN.NORC.Elections.final$BLM_supp <- sapply(CNN.NORC.Elections.final$BLM_supp,  function(x) 3 - x)


```


### IV - Income

```{r Income, D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. checking the variable of interest
#
CNN.NORC.Elections.final$INCOME
#
#2. Checking the question and the labels for the final dataset.. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("INCOME")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("INCOME")])  # Values check
#
#3. Checking frequencies 
#
table(CNN.NORC.Elections.final$INCOME, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.NORC.Elections.final$INCOME, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.NORC.Elections.final$INCOME, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$HIncome <- CNN.NORC.Elections.final$INCOME
#
#5. Selecting options that have data 
#
CNN.NORC.Elections.final[CNN.NORC.Elections.final$HIncome %in% c(9), "HIncome"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
CNN.NORC.Elections.final.meta.income <- CNN.NORC.Elections.final[, c("BLM_supp","HIncome")]
#
```

### IV - Age

```{r Age, D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. Instructions to check the variable of interest
#
CNN.NORC.Elections.final$AGE
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("AGE")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("AGE")])  # Values check
#
#3. Checking frequencies 
#
table(CNN.NORC.Elections.final$AGE, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.NORC.Elections.final$AGE, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.NORC.Elections.final$INCOME, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$RAge <- CNN.NORC.Elections.final$AGE
#
#5. Selecting options that have data 
#
CNN.NORC.Elections.final[CNN.NORC.Elections.final$RAge %in% c(9), "RAge"] <- NA
#prop.table(table(CNN.NORC.Elections.final$RAge, useNA = "ifany"))          # Checking proportions
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
CNN.NORC.Elections.final.meta.age <- CNN.NORC.Elections.final[, c("BLM_supp","RAge")]
#
```

<br>

### IV - Gender

```{r Gender, D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. Instructions to check the variable of interest
#
CNN.NORC.Elections.final$SEX
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("SEX")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("SEX")])  # Values check
#
#3. Checking frequencies 
#
table(CNN.NORC.Elections.final$SEX, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.NORC.Elections.final$SEX, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.NORC.Elections.final$SEX, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$RGender <- CNN.NORC.Elections.final$SEX
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
CNN.NORC.Elections.final.meta.gender <- CNN.NORC.Elections.final[, c("BLM_supp","RGender")]
#
```

<br>


### IV - Education

```{r Education, D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. Instructions to check the variable of interest
#
CNN.NORC.Elections.final$EEDUC
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("EDUC")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("EDUC")])  # Values check
#
#3. Checking frequencies 
#
table(CNN.NORC.Elections.final$EEDUC, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.NORC.Elections.final$EEDUC, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.NORC.Elections.final$EEDUC, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$REducation <- CNN.NORC.Elections.final$EEDUC
#
#5. Selecting options that have data 
#
CNN.NORC.Elections.final[CNN.NORC.Elections.final$REducation %in% c(9), "REducation"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.Elections.final.meta.education <- CNN.NORC.Elections.final[, c("BLM_supp","REducation")]
#
```


### IV - Urbanicity

```{r Urbanicity, D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. Instructions to check the variable of interest
#
CNN.NORC.Elections.final$URBAN
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("URBAN")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("URBAN")])  # Values check
#
#3. Checking frequencies 
#
table(CNN.NORC.Elections.final$URBAN, useNA = "ifany")                      # Checking frequencies
prop.table(table(CNN.NORC.Elections.final$URBAN, useNA = "ifany"))          # Checking proportions
round(prop.table(table(CNN.NORC.Elections.final$URBAN, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$Urbanicity <- CNN.NORC.Elections.final$URBAN
#
#5. Selecting options that have data 
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Urbanicity %in% c(99), "Urbanicity"] <- NA
#
#RECODING
CNN.NORC.Elections.final$Urbanicity <- sapply(CNN.NORC.Elections.final$Urbanicity,  function(x) 4 - x)
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
CNN.NORC.Elections.final.meta.urbanicity <- CNN.NORC.Elections.final[, c("BLM_supp","Urbanicity")]
#
```

<br>



### IV - Partisanship - Republicans

```{r Partisanship - Republicans, D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Republican
#CNN.NORC.Elections$PARTY1
CNN.NORC.Elections.final$PARTY1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("PARTY1")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("PARTY1")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.Elections.final$PARTY1, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.Elections.final$PARTY1, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.Elections.final$PARTY1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$Partisanship_Rep <- CNN.NORC.Elections.final$PARTY1
#
#5. Selecting options that have data 
#
# NA
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Partisanship_Rep %in% c(4,9), "Partisanship_Rep"] <- NA
#
#
#6. Recoding the IV (if necessary)
CNN.NORC.Elections.final$Partisanship_Rep <- as.numeric(CNN.NORC.Elections.final$Partisanship_Rep)
CNN.NORC.Elections.final$Partisanship_Rep <- car::recode(CNN.NORC.Elections.final$Partisanship_Rep, ' "1"="3";"2"="1"; "3"="2" ')
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.Elections.final.meta.partisanshiprep <- CNN.NORC.Elections.final[, c("BLM_supp","Partisanship_Rep")]
#
```


<br>



### IV - Ideology

```{r Ideology, D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CNN.NORC.Elections$IDEOLOGY
CNN.NORC.Elections.final$IDEOLOGY
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("IDEOLOGY")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("IDEOLOGY")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.Elections.final$IDEOLOGY, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.Elections.final$IDEOLOGY, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.Elections.final$IDEOLOGY, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$Ideol_Conservative <- CNN.NORC.Elections.final$IDEOLOGY
#
#5. Selecting options that have data 
#
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Ideol_Conservative %in% c(0), "Ideol_Conservative"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.Elections.final.meta.ideology <- CNN.NORC.Elections.final[, c("BLM_supp","Ideol_Conservative")]
#
```


<br>


### IV - Registered to Vote

```{r Registered to Vote, D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. Instructions to check the variable of interest
#
CNN.NORC.Elections.final$REGISTER
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("REGISTER")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("REGISTER")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.Elections.final$REGISTER, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.Elections.final$REGISTER, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.Elections.final$REGISTER, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$VoteReg <- CNN.NORC.Elections.final$REGISTER
#
#5. Selecting options that have data 
#
CNN.NORC.Elections.final[CNN.NORC.Elections.final$VoteReg %in% c(9), "VoteReg"] <- NA
#
#6. Recoding the IV (if necessary)
CNN.NORC.Elections.final$VoteReg <- sapply(CNN.NORC.Elections.final$VoteReg,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.Elections.final.meta.votereg <- CNN.NORC.Elections.final[, c("BLM_supp","VoteReg")]
#
```


<br>


### IV - Obama Approval

```{r Obama Approval, D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Obama Approval
#CNN.NORC.Elections$APPROVAL
CNN.NORC.Elections.final$APPROVAL
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("APPROVAL")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("APPROVAL")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.Elections.final$APPROVAL, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.Elections.final$APPROVAL, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.Elections.final$APPROVAL, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$Obama_App <- CNN.NORC.Elections.final$APPROVAL
#
#5. Selecting options that have data 
#
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Obama_App %in% c(9), "Obama_App"] <- NA
#
#6. Recoding the IV (if necessary)
CNN.NORC.Elections.final$Obama_App <- sapply(CNN.NORC.Elections.final$Obama_App,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.Elections.final.meta.obamaapp <- CNN.NORC.Elections.final[, c("BLM_supp","Obama_App")]
#
```


<br>


### IV - Hillary - Favorability

```{r Hillary - D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. Instructions to check the variable of interest
#
# Favorability towards Hillary Clinton
#CNN.NORC.Elections$Q10A
CNN.NORC.Elections.final$Q10A
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("Q10A")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("Q10A")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.Elections.final$Q10A, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.Elections.final$Q10A, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.Elections.final$Q10A, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$Hillary_Fav <- CNN.NORC.Elections.final$Q10A
#
#5. Selecting options that have data 
#
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Hillary_Fav %in% c(3), "Hillary_Fav"] <- NA
#
#6. Recoding the IV (if necessary)
CNN.NORC.Elections.final$Hillary_Fav <- sapply(CNN.NORC.Elections.final$Hillary_Fav,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.Elections.final.meta.hillaryfav <- CNN.NORC.Elections.final[, c("BLM_supp","Hillary_Fav")]
#
```


<br>


### IV - Trump - Favorability

```{r Trump - D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. Instructions to check the variable of interest
#
# Favorability towards Trump
#CNN.NORC.Elections$Q10E
CNN.NORC.Elections.final$Q10E
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("Q10E")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("Q10E")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.Elections.final$Q10E, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.Elections.final$Q10E, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.Elections.final$Q10E, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$Trump_Fav <- CNN.NORC.Elections.final$Q10E
#
#5. Selecting options that have data 
#
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Trump_Fav %in% c(3,4,9), "Trump_Fav"] <- NA
#
#6. Recoding the IV (if necessary)
CNN.NORC.Elections.final$Trump_Fav <- sapply(CNN.NORC.Elections.final$Trump_Fav,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.Elections.final.meta.trumpfav <- CNN.NORC.Elections.final[, c("BLM_supp","Trump_Fav")]
#
```


<br>


### IV - Race - Blacks

```{r Race - Blacks, D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. Instructions to check the variable of interest
#CNN.NORC.Elections$RACE1
CNN.NORC.Elections.final$RACE1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("RACE1")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("RACE1")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.Elections.final$RACE1, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.Elections.final$RACE1, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.Elections.final$RACE1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$Race_Blacks <- CNN.NORC.Elections.final$RACE1
#
CNN.NORC.Elections.final[CNN.NORC.Elections.final$HISPANIC %in% c('1'),"Race_Blacks"] <- 3
#table(CNN.NORC.final$Race, useNA = "ifany")   

#5. Selecting options that have data 
#
# Check frequencies of hispanics across race categories
#ftable(RACE1 ~ HISPANIC, data = CNN.NORC.Elections.final)
# NA
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Race_Blacks %in% c(5,9), "Race_Blacks"] <- NA
#
# Other races
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Race_Blacks %in% c(1,3,4), "Race_Blacks"] <- 0
#
# Other races
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Race_Blacks %in% c(2), "Race_Blacks"] <- 1
#

#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.Elections.final.meta.raceblacks <- CNN.NORC.Elections.final[, c("BLM_supp","Race_Blacks")]
#
```


<br>


### IV - Race - Whites

```{r Race - Whites, D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CNN.NORC.Elections$RACE1
CNN.NORC.Elections.final$RACE1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("RACE1")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("RACE1")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.Elections.final$RACE1, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.Elections.final$RACE1, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.Elections.final$RACE1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$Race_Whites <- CNN.NORC.Elections.final$RACE1
#
CNN.NORC.Elections.final[CNN.NORC.Elections.final$HISPANIC %in% c('1'),"Race_Whites"] <- 3
#table(CNN.NORC.final$Race, useNA = "ifany")   

#5. Selecting options that have data 
#
# Check frequencies of hispanics across race categories
#ftable(RACE1 ~ HISPANIC, data = CNN.NORC.final)
# NA
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Race_Whites %in% c(5,9), "Race_Whites"] <- NA
#
# Other races
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Race_Whites %in% c(2,3,4), "Race_Whites"] <- 0
#

#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.Elections.final.meta.racewhites <- CNN.NORC.Elections.final[, c("BLM_supp","Race_Whites")]
#
```


<br>


### IV - Race - Hispanic

```{r Race - Hispanic, D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CNN.NORC.Elections$RACE1
CNN.NORC.Elections.final$RACE1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("RACE1")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("RACE1")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.Elections.final$RACE1, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.Elections.final$RACE1, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.Elections.final$RACE1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$Race_Hisp <- CNN.NORC.Elections.final$RACE1
#
CNN.NORC.Elections.final[CNN.NORC.Elections.final$HISPANIC %in% c('1'),"Race_Hisp"] <- 3
#table(CNN.NORC.final$Race, useNA = "ifany")   

#5. Selecting options that have data 
#
# Check frequencies of hispanics across race categories
#ftable(RACE1 ~ HISPANIC, data = CNN.NORC.Elections.final)
# NA
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Race_Hisp %in% c(5,9), "Race_Hisp"] <- NA
#
# Other races
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Race_Hisp %in% c(1,2,4), "Race_Hisp"] <- 0
#
# Other races
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Race_Hisp %in% c(3), "Race_Hisp"] <- 1
#

#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.Elections.final.meta.racehispanic <- CNN.NORC.Elections.final[, c("BLM_supp","Race_Hisp")]
#
```


<br>



### IV - Race - Asians

```{r Race - Asians, D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CNN.NORC.Elections$RACE1
CNN.NORC.Elections.final$RACE1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("RACE1")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("RACE1")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.Elections.final$RACE1, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.Elections.final$RACE1, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.Elections.final$RACE1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$Race_Asians <- CNN.NORC.Elections.final$RACE1
#
CNN.NORC.Elections.final[CNN.NORC.Elections.final$HISPANIC %in% c('1'),"Race_Asians"] <- 3
#table(CNN.NORC.final$Race, useNA = "ifany")   

#5. Selecting options that have data 
#
# Check frequencies of hispanics across race categories
#ftable(RACE1 ~ HISPANIC, data = CNN.NORC.Elections.final)
# NA
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Race_Asians %in% c(5,9), "Race_Asians"] <- NA
#
# Other races
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Race_Asians %in% c(1,2,3), "Race_Asians"] <- 0
#
# Other races
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Race_Asians %in% c(4), "Race_Asians"] <- 1
#

#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.Elections.final.meta.raceasians <- CNN.NORC.Elections.final[, c("BLM_supp","Race_Asians")]
#
```

### IV - Future of the country
```{r Future of the country, D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. Instructions to check the variable of interest
#

CNN.NORC.Elections.final$Q3
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("Q3")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("Q3")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.Elections.final$Q3, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.NORC.Elections.final$APPROVAL, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.NORC.Elections.final$APPROVAL, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$Country_Future <- CNN.NORC.Elections.final$Q3
#
#5. Selecting options that have data 
#
#
#6. Recoding the IV (if necessary)
CNN.NORC.Elections.final$Country_Future <- sapply(CNN.NORC.Elections.final$Country_Future,  function(x) 5 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.Elections.final.meta.countryfuture <- CNN.NORC.Elections.final[, c("BLM_supp","Country_Future")]
#
```


### IV - Country Economy

```{r Country Economy, D8. CNN NORC Poll 2016 Presidential Elections, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CBS.2016$TRACK
CNN.NORC.Elections.final$Q2A
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(CNN.NORC.Elections.final[,c("Q2A")])   # Values check
sjlabelled::get_labels(CNN.NORC.Elections.final[,c("Q2A")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.NORC.Elections.final$Q2A, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CBS.2016.final$TRACK, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CBS.2016.final$TRACK, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
CNN.NORC.Elections.final$Country_Econ <- CNN.NORC.Elections.final$Q2A
#
#5. Selecting options that have data 
#
CNN.NORC.Elections.final[CNN.NORC.Elections.final$Country_Econ %in% c(9), "Country_Econ"] <- NA
#
#6. Recoding the IV (if necessary)
CNN.NORC.Elections.final$Country_Econ <- sapply(CNN.NORC.Elections.final$Country_Econ,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
CNN.NORC.Elections.final.meta.countryecon <- CNN.NORC.Elections.final[, c("BLM_supp","Country_Econ")]
#

```


<br>



## D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll
   
```{r loading data - D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}


######### PATH L.M. ####################
Kaiser.2020  <- haven::read_spss("Roper data/Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll/31117492.por")

######### PATH F.A. ####################
# Kaiser.2020  <- haven::read_spss("C:/Users/Flavio/Dropbox/Tamara/BLM/Roper data/Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll/31117492.por")

######### PATH T.M. ####################
#Kaiser.2020 <- haven::read_spss("C:/Users/tmmar/Dropbox/Tamara/BLM/Roper data/Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll/31117492.por")


labelled::look_for(Kaiser.2020) %>% dplyr::as_tibble() -> Kaiser.2020.codebook 

```

<br> 

### DV

* Q16. Overall, do you (support) or (oppose) the recent protests against police violence?

   - (1) Support
   - (2) Oppose
   - (8) Don't know
   - (9) Refused



```{r DV, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}

Kaiser.2020$Q16
#
#2. Check the question and the labels 
sjlabelled::get_label(Kaiser.2020[,c("Q16")])   # Values check
sjlabelled::get_labels(Kaiser.2020[,c("Q16")])  # Values check
#
#3. Checking frequencies
table(Kaiser.2020$Q16, useNA = "ifany")                      # Checking frequencies
prop.table(table(Kaiser.2020$Q16, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Kaiser.2020$Q16, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating a new dataset to manipulate variables 
Kaiser.2020.final <- Kaiser.2020
#
#5. Creating Manipulated DV (BLM_supp) 
Kaiser.2020.final$BLM_supp <- Kaiser.2020.final$Q16
#
#6. Selecting options that have data (= removing missing data)
#
Kaiser.2020.final <- Kaiser.2020.final[Kaiser.2020.final$BLM_supp %in% c(1, 2),]
#
#7. Recoding the DV (if necessary)
#
Kaiser.2020.final$BLM_supp <- sapply(Kaiser.2020.final$BLM_supp,  function(x) 3 - x)


```


### IV - Income

```{r Income, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. checking the variable of interest
#
Kaiser.2020.final$INCOME
#
#2. Checking the question and the labels for the final dataset.. 
sjlabelled::get_label(Kaiser.2020.final[,c("INCOME")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("INCOME")])  # Values check
#
#3. Checking frequencies 
#
table(Kaiser.2020.final$INCOME, useNA = "ifany")                      # Checking frequencies
prop.table(table(Kaiser.2020.final$INCOME, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Kaiser.2020.final$INCOME, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$HIncome <- Kaiser.2020.final$INCOME
#
#5. Selecting options that have data 
#
Kaiser.2020.final[Kaiser.2020.final$HIncome %in% c(98,99), "HIncome"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Kaiser.2020.final.meta.income <- Kaiser.2020.final[, c("BLM_supp","HIncome")]
#
```

### IV - Age

```{r Age, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#
Kaiser.2020.final$AGE
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(Kaiser.2020.final[,c("AGE")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("AGE")])  # Values check
#
#3. Checking frequencies 
#
table(Kaiser.2020.final$AGE, useNA = "ifany")                      # Checking frequencies
prop.table(table(Kaiser.2020.final$AGE, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Kaiser.2020.final$INCOME, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$RAge <- Kaiser.2020.final$AGE
#
#5. Selecting options that have data 
Kaiser.2020.final[Kaiser.2020.final$RAge %in% c(99), "RAge"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Kaiser.2020.final.meta.age <- Kaiser.2020.final[, c("BLM_supp","RAge")]
#
```


<br>


### IV - Gender

```{r Gender, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#
Kaiser.2020.final$RSEX
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(Kaiser.2020.final[,c("RSEX")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("RSEX")])  # Values check
#
#3. Checking frequencies 
#
table(Kaiser.2020.final$RSEX, useNA = "ifany")                      # Checking frequencies
prop.table(table(Kaiser.2020.final$RSEX, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Kaiser.2020.final$RSEX, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$RGender <- Kaiser.2020.final$RSEX
#
#5. Selecting options that have data 
Kaiser.2020.final[Kaiser.2020.final$RGender %in% c(3,8,9), "RGender"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
# 
Kaiser.2020.final.meta.gender <- Kaiser.2020.final[, c("BLM_supp","RGender")]
#
```



<br>

### IV - Education

```{r Education, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#
Kaiser.2020.final$EDUC
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Kaiser.2020.final[,c("EDUC")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("EDUC")])  # Values check
#
#3. Checking frequencies 
#
table(Kaiser.2020.final$EDUC, useNA = "ifany")                      # Checking frequencies
prop.table(table(Kaiser.2020.final$EDUC, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Kaiser.2020.final$EDUC, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$REducation <- Kaiser.2020.final$EDUC
#
#5. Selecting options that have data 
#
Kaiser.2020.final[Kaiser.2020.final$REducation %in% c(99), "REducation"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Kaiser.2020.final.meta.education <- Kaiser.2020.final[, c("BLM_supp","REducation")]
#
```


<br>


### IV - Partisanship - Republicans

```{r Partisanship - Republicans, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Republican
Kaiser.2020.final$PARTY
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Kaiser.2020.final[,c("PARTY")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("PARTY")])  # Values check
#
#3. Checking frequencies 
#
#table(Kaiser.2020.final$PARTY, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Kaiser.2020.final$PARTY, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Kaiser.2020.final$PARTY, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$Partisanship_Rep <- Kaiser.2020.final$PARTY
#
#5. Selecting options that have data 
#
# NA
Kaiser.2020.final[Kaiser.2020.final$Partisanship_Rep %in% c(4,8,9), "Partisanship_Rep"] <- NA
#
#6. Recoding the IV (if necessary)
Kaiser.2020.final$Partisanship_Rep <- as.numeric(Kaiser.2020.final$Partisanship_Rep)
Kaiser.2020.final$Partisanship_Rep <- car::recode(Kaiser.2020.final$Partisanship_Rep, ' "1"="3";"2"="1"; "3"="2" ')
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Kaiser.2020.final.meta.partisanshiprep <- Kaiser.2020.final[, c("BLM_supp","Partisanship_Rep")]
#
```


<br>




### IV - Ideology

```{r Ideology, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Kaiser.2020$IDEOLOGY
Kaiser.2020.final$IDEOLOGY
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Kaiser.2020.final[,c("IDEOLOGY")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("IDEOLOGY")])  # Values check
#
#3. Checking frequencies 
#
#table(Kaiser.2020.final$IDEOLOGY, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Kaiser.2020.final$IDEOLOGY, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Kaiser.2020.final$IDEOLOGY, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$Ideol_Conservative <- Kaiser.2020.final$IDEOLOGY
#
#5. Selecting options that have data 
#
Kaiser.2020.final[Kaiser.2020.final$Ideol_Conservative %in% c(8,9), "Ideol_Conservative"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Kaiser.2020.final.meta.ideology <- Kaiser.2020.final[, c("BLM_supp","Ideol_Conservative")]
#
```


<br>

### IV - Police Misconduct

```{r Police Misconduct, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#
Kaiser.2020$Q8A
Kaiser.2020.final$Q8A
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Kaiser.2020.final[,c("Q8A")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("Q8A")])  # Values check
#
#3. Checking frequencies 
#
table(Kaiser.2020.final$Q8A, useNA = "ifany")                      # Checking frequencies
prop.table(table(Kaiser.2020.final$Q8A, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Kaiser.2020.final$Q8A, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$PoliceMisc <- Kaiser.2020.final$Q8A
#
#5. Selecting options that have data 
#
Kaiser.2020.final[Kaiser.2020.final$PoliceMisc %in% c(8,9), "PoliceMisc"] <- NA
#
#6. Recoding the IV (if necessary)
Kaiser.2020.final$PoliceMisc <- as.numeric(Kaiser.2020.final$PoliceMisc)
Kaiser.2020.final$PoliceMisc <- car::recode(Kaiser.2020.final$PoliceMisc, ' "1"="3"; "2"="1"; "3"="2" ')
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Kaiser.2020.final.meta.policemisconduct <- Kaiser.2020.final[, c("BLM_supp","PoliceMisc")]
#
```


<br>


### IV - Registered to Vote

```{r Registered to Vote, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#
Kaiser.2020$RVOTE
Kaiser.2020.final$RVOTE
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Kaiser.2020.final[,c("RVOTE")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("RVOTE")])  # Values check
#
#3. Checking frequencies 
#
#table(Kaiser.2020.final$RVOTE, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Kaiser.2020.final$RVOTE, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Kaiser.2020.final$RVOTE, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$VoteReg <- Kaiser.2020.final$RVOTE
#
#5. Selecting options that have data 
#
Kaiser.2020.final[Kaiser.2020.final$VoteReg %in% c(8,9), "VoteReg"] <- NA
#
#6. Recoding the IV (if necessary)
Kaiser.2020.final$VoteReg <- sapply(Kaiser.2020.final$VoteReg,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Kaiser.2020.final.meta.votereg <- Kaiser.2020.final[, c("BLM_supp","VoteReg")]
#
```


<br>



### IV - Who would better handle Race Relations: Trump or Biden?

```{r Who would better handle Race Relations: Trump or Biden?, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Kaiser.2020$Q3C
Kaiser.2020.final$Q3C
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Kaiser.2020.final[,c("Q3C")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("Q3C")])  # Values check
#
#3. Checking frequencies 
#
#table(Kaiser.2020.final$Q3C, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Kaiser.2020.final$Q3C, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Kaiser.2020.final$Q3C, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$BidenvsTrump_Race <- Kaiser.2020.final$Q3C
#
#5. Selecting options that have data 
#
Kaiser.2020.final[Kaiser.2020.final$BidenvsTrump_Race %in% c(3,4,5,8,9), "BidenvsTrump_Race"] <- NA
#
#6. Recoding the IV (if necessary)
#Kaiser.2020.final$DTJB_RaceRelations <- sapply(Kaiser.2020.final$DTJB_RaceRelations,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Kaiser.2020.final.meta.bidentrump_race <- Kaiser.2020.final[, c("BLM_supp","BidenvsTrump_Race")]
#
```


<br>




### IV - Attended Racial Protests

```{r Attended Racial Protests, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#Attended Highest
#Kaiser.2020$Q15_2
Kaiser.2020.final$Q15_2
Kaiser.2020.final$Q15_3
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Kaiser.2020.final[,c("Q15_2")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("Q15_2")])  # Values check
#
#3. Checking frequencies 
#
#table(Kaiser.2020.final$Q15_2, useNA = "ifany")                # Checking #frequencies
#prop.table(table(Kaiser.2020.final$Q15_2, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Kaiser.2020.final$Q15_2, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#
#4. Creating Manipulated variable with the same name for all datasets
#

Kaiser.2020.final$Attend_RacialProtest.A <- Kaiser.2020.final$Q15_2
Kaiser.2020.final$Attend_RacialProtest.B <- Kaiser.2020.final$Q15_3
#5. Selecting options that have data 
#
#Kaiser.2020.final[Kaiser.2020.final$Attend_RacialProtest %in% c(9), "Attend_RacialProtest"] <- NA
#
#6. Recoding the IV (if necessary)
#Kaiser.2020.final$Attend_RacialProtest <- sapply(Kaiser.2020.final$Attend_RacialProtest,  function(x) 3 - x)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Kaiser.2020.final$Attend_RacialProtest <- rowMeans(Kaiser.2020.final[ , c("Attend_RacialProtest.A", "Attend_RacialProtest.B")], na.rm=TRUE)
#
Kaiser.2020.final.meta.attendracialprotest <- Kaiser.2020.final[, c("BLM_supp","Attend_RacialProtest")]
#
```

<br>




### IV - Personal experience with discrimination

```{r Personal discrimination, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#
Kaiser.2020.final$Q13A
Kaiser.2020.final$Q13B
Kaiser.2020.final$Q13C
Kaiser.2020.final$Q13D
Kaiser.2020.final$Q13E

#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Kaiser.2020.final[,c("Q13A")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("Q13A")])  # Values check
#
#3. Checking frequencies 
#
#table(Kaiser.2020.final$Q13A, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Kaiser.2020.final$Q13A, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Kaiser.2020.final$Q13A, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$PersDiscr.A <- Kaiser.2020.final$Q13A
Kaiser.2020.final$PersDiscr.B <- Kaiser.2020.final$Q13B
Kaiser.2020.final$PersDiscr.C <- Kaiser.2020.final$Q13C
Kaiser.2020.final$PersDiscr.D <- Kaiser.2020.final$Q13D
Kaiser.2020.final$PersDiscr.E <- Kaiser.2020.final$Q13E

#
#5. Selecting options that have data 
#
Kaiser.2020.final[Kaiser.2020.final$PersDiscr.A %in% c(3), "PersDiscr.A"] <- NA
Kaiser.2020.final[Kaiser.2020.final$PersDiscr.B %in% c(3, 8), "PersDiscr.B"] <- NA
Kaiser.2020.final[Kaiser.2020.final$PersDiscr.C %in% c(3, 9), "PersDiscr.C"] <- NA
Kaiser.2020.final[Kaiser.2020.final$PersDiscr.D %in% c(3, 8), "PersDiscr.D"] <- NA
Kaiser.2020.final[Kaiser.2020.final$PersDiscr.E %in% c(3, 8), "PersDiscr.E"] <- NA

#

#6. Recoding the IV (if necessary)
#
Kaiser.2020.final$PersDiscr.A.rec <- Kaiser.2020.final$PersDiscr.A
Kaiser.2020.final$PersDiscr.A.rec <- sapply(Kaiser.2020.final$PersDiscr.A.rec,  function(x) 3 - x)
#
Kaiser.2020.final$PersDiscr.B.rec <- Kaiser.2020.final$PersDiscr.B
Kaiser.2020.final$PersDiscr.B.rec <- sapply(Kaiser.2020.final$PersDiscr.B.rec,  function(x) 3 - x)
# 
Kaiser.2020.final$PersDiscr.C.rec <- Kaiser.2020.final$PersDiscr.C
Kaiser.2020.final$PersDiscr.C.rec <- sapply(Kaiser.2020.final$PersDiscr.C.rec,  function(x) 3 - x)
#
# 
Kaiser.2020.final$PersDiscr.D.rec <- Kaiser.2020.final$PersDiscr.D
Kaiser.2020.final$PersDiscr.D.rec <- sapply(Kaiser.2020.final$PersDiscr.D.rec,  function(x) 3 - x)
#
# 
Kaiser.2020.final$PersDiscr.E.rec <- Kaiser.2020.final$PersDiscr.E
Kaiser.2020.final$PersDiscr.E.rec <- sapply(Kaiser.2020.final$PersDiscr.E.rec,  function(x) 3 - x)
#
#
# Averaging the variables
Kaiser.2020.final$PersDiscr <- rowMeans(Kaiser.2020.final[ , c("PersDiscr.A.rec", "PersDiscr.B.rec", "PersDiscr.C.rec", "PersDiscr.D.rec", "PersDiscr.E.rec")], na.rm=TRUE)
#?rowMeans
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Kaiser.2020.final.meta.persdiscr <- Kaiser.2020.final[, c("BLM_supp","PersDiscr")]
#
```




### IV - Marital Status

```{r Marital Status, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Married
#Kaiser.2020$MARITAL
Kaiser.2020.final$MARITAL
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Kaiser.2020.final[,c("MARITAL")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("MARITAL")])  # Values check
#
#3. Checking frequencies 
#
#table(Kaiser.2020.final$MARITAL, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Kaiser.2020.final$MARITAL, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Kaiser.2020.final$MARITAL, useNA = "ifany")),2) # Checking %s with 2 decimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$MaritalStatus <- Kaiser.2020.final$MARITAL
#
#5. Selecting options that have data 
#
# NA
Kaiser.2020.final[Kaiser.2020.final$MaritalStatus %in% c(2,3,4,5,8,9), "MaritalStatus"] <- NA
#
# Never been Married
Kaiser.2020.final[Kaiser.2020.final$MaritalStatus %in% c(6), "MaritalStatus"] <- 0
#
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Kaiser.2020.final.meta.maritalstatus <- Kaiser.2020.final[, c("BLM_supp","MaritalStatus")]
#
```


<br>


### IV - Employment Status

```{r Employment Status, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Married
#Kaiser.2020$EMPLOY
Kaiser.2020.final$EMPLOY
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Kaiser.2020.final[,c("EMPLOY")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("EMPLOY")])  # Values check
#
#3. Checking frequencies 
#
#table(Kaiser.2020.final$EMPLOY, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Kaiser.2020.final$EMPLOY, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Kaiser.2020.final$EMPLOY, useNA = "ifany")),2) # Checking %s with 2 decimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$EmploymentStatus <- Kaiser.2020.final$EMPLOY
#
#5. Selecting options that have data 
#
# NA
Kaiser.2020.final[Kaiser.2020.final$EmploymentStatus %in% c(3,4,5,7,8,98,99), "EmploymentStatus"] <- NA
#
# Working
Kaiser.2020.final[Kaiser.2020.final$EmploymentStatus %in% c(1,2), "EmploymentStatus"] <- 1
#
# Retired
Kaiser.2020.final[Kaiser.2020.final$EmploymentStatus %in% c(6), "EmploymentStatus"] <- 0
#

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Kaiser.2020.final.meta.employmentstatus <- Kaiser.2020.final[, c("BLM_supp","EmploymentStatus")]
#
```


<br>



### IV - Prospective Vote 2020 - Trump VS Biden

```{r Prospective Vote 2020 - Trump VS Biden, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Married
#Kaiser.2020$SWING
Kaiser.2020.final$SWING
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Kaiser.2020.final[,c("SWING")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("SWING")])  # Values check
#
#3. Checking frequencies 
#
#table(Kaiser.2020.final$SWING, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Kaiser.2020.final$SWING, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Kaiser.2020.final$SWING, useNA = "ifany")),2) # Checking %s with 2 ecimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$Vote2020_TrumpvsBiden <- Kaiser.2020.final$SWING
#
#5. Selecting options that have data 
#
#NA + Undecided(5), Vote for Someone else(6), Dont plan to vote(7)
Kaiser.2020.final[Kaiser.2020.final$Vote2020_TrumpvsBiden %in% c(5, 6, 7, 8, 9), "Vote2020_TrumpvsBiden"] <- NA
#
#6. Recoding the IV (if necessary)
Kaiser.2020.final$Vote2020_TrumpvsBiden <- sapply(Kaiser.2020.final$Vote2020_TrumpvsBiden,  function(x) 5 - x)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Kaiser.2020.final.meta.pvote20 <- Kaiser.2020.final[, c("BLM_supp","Vote2020_TrumpvsBiden")]
#
```


<br>


### IV - Trump Approval

```{r Trump Approval, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll - Wave 1, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Kaiser.2020$TRUMPAPP
Kaiser.2020.final$TRUMPAPP
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Kaiser.2020.final[,c("TRUMPAPP")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("TRUMPAPP")])  # Values check
#
#3. Checking frequencies 
#
#table(Kaiser.2020.final$TRUMPAPP, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Kaiser.2020.final$TRUMPAPP, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Kaiser.2020.final$TRUMPAPP, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$Trump_App <- Kaiser.2020.final$TRUMPAPP
#
#5. Selecting options that have data 
#
Kaiser.2020.final[Kaiser.2020.final$Trump_App %in% c(8,9), "Trump_App"] <- NA
#
#6. Recoding the IV (if necessary)
#
#
Kaiser.2020.final$Trump_App <- sapply(Kaiser.2020.final$Trump_App,  function(x) 5 - x)
#     
#
                                                              
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Kaiser.2020.final.meta.trumpapp <- Kaiser.2020.final[, c("BLM_supp","Trump_App")]
#
#table(Kaiser.2020.final$TRUMPAPP, useNA = "ifany")                    

#table(Kaiser.2020.final$Trump_App, useNA = "ifany")                      

```



### IV - Race - Blacks

```{r Race - Blacks, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Kaiser.2020$RACETHN
Kaiser.2020.final$RACETHN
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Kaiser.2020.final[,c("RACETHN")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("RACETHN")])  # Values check
#
#3. Checking frequencies 
#
#table(Kaiser.2020.final$RACETHN, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Kaiser.2020.final$RACETHN, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Kaiser.2020.final$RACETHN, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$Race_Blacks <- Kaiser.2020.final$RACETHN
#
#5. Selecting options that have data 
#
# NA
Kaiser.2020.final[Kaiser.2020.final$Race_Blacks %in% c(4, 9), "Race_Blacks"] <- NA
#
# Other races
Kaiser.2020.final[Kaiser.2020.final$Race_Blacks %in% c(1, 3), "Race_Blacks"] <- 0
#
#Blacks
Kaiser.2020.final[Kaiser.2020.final$Race_Blacks %in% c(2), "Race_Blacks"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Kaiser.2020.final.meta.raceblacks <- Kaiser.2020.final[, c("BLM_supp","Race_Blacks")]
#
```


<br>



### IV - Race - Whites

```{r Race - Whites, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Kaiser.2020$RACETHN
Kaiser.2020.final$RACETHN
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Kaiser.2020.final[,c("RACETHN")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("RACETHN")])  # Values check
#
#3. Checking frequencies 
#
#table(Kaiser.2020.final$RACETHN, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Kaiser.2020.final$RACETHN, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Kaiser.2020.final$RACETHN, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$Race_Whites <- Kaiser.2020.final$RACETHN
#
#5. Selecting options that have data 
#
# NA
Kaiser.2020.final[Kaiser.2020.final$Race_Whites %in% c(4, 9), "Race_Whites"] <- NA
#
# Other races
Kaiser.2020.final[Kaiser.2020.final$Race_Whites %in% c(2, 3), "Race_Whites"] <- 0
#
#Whites
#Kaiser.2020.final[Kaiser.2020.final$Race_Whites %in% c(1), "Race_Whites"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Kaiser.2020.final.meta.racewhites <- Kaiser.2020.final[, c("BLM_supp","Race_Whites")]
#
```


<br>


### IV - Race - Hispanic

```{r Race - Hispanic, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Kaiser.2020$RACETHN
Kaiser.2020.final$RACETHN
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Kaiser.2020.final[,c("RACETHN")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("RACETHN")])  # Values check
#
#3. Checking frequencies 
#
#table(Kaiser.2020.final$RACETHN, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Kaiser.2020.final$RACETHN, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Kaiser.2020.final$RACETHN, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$Race_Hisp <- Kaiser.2020.final$RACETHN
#
#5. Selecting options that have data 
#
# NA
Kaiser.2020.final[Kaiser.2020.final$Race_Hisp %in% c(4, 9), "Race_Hisp"] <- NA
#
# Other races
Kaiser.2020.final[Kaiser.2020.final$Race_Hisp %in% c(1,2), "Race_Hisp"] <- 0
#
#Hisp
Kaiser.2020.final[Kaiser.2020.final$Race_Hisp %in% c(3), "Race_Hisp"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Kaiser.2020.final.meta.racehispanic <- Kaiser.2020.final[, c("BLM_supp","Race_Hisp")]
#
```


<br>



### IV - Future of the country

```{r Future of the country, D9. Kaiser Family Foundation Poll June 2020 Kaiser Health Tracking Poll, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Kaiser.2020$Q1
Kaiser.2020.final$Q1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Kaiser.2020.final[,c("Q1")])   # Values check
sjlabelled::get_labels(Kaiser.2020.final[,c("Q1")])  # Values check
#
#3. Checking frequencies 
#
#table(Kaiser.2020.final$Q1, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Kaiser.2020.final$Q1, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Kaiser.2020.final$Q1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Kaiser.2020.final$Country_Future <- Kaiser.2020.final$Q1
#
#5. Selecting options that have data 
#
Kaiser.2020.final[Kaiser.2020.final$Country_Future %in% c(8, 9), "Country_Future"] <- NA
#
#6. Recoding the IV (if necessary)
Kaiser.2020.final$Country_Future <- sapply(Kaiser.2020.final$Country_Future,  function(x) 5 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Kaiser.2020.final.meta.countryfuture <- Kaiser.2020.final[, c("BLM_supp","Country_Future")]
#
```


<br>





## D11. NPR PBS News Hour Marist Poll August 2020

```{r loading data - D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}

######### PATH L.M. ####################
NPR.Aug <- haven::read_spss("Roper data/NPRPBS NewsHourMarist Poll August 2020/31117648.por")

######### PATH F.A. ####################
# NPR.Aug <- haven::read_spss("C:/Users/Flavio/Dropbox/Tamara/BLM/Roper data/NPRPBS NewsHourMarist Poll August 2020/31117648.por")

######### PATH T.M. ####################
#NPR.Aug <- haven::read_spss("C:/Users/tmmar/Dropbox/Tamara/BLM/Roper data/NPRPBS NewsHourMarist Poll August 2020/31117648.por")


labelled::look_for(NPR.Aug) %>% dplyr::as_tibble() -> NPR.Aug.codebook 

```

### DV

* BLM020. In general, do you have a favorable or unfavorable impression of the Black Lives Matter movement?
   - (1) Favorable
   - (2) Unfavorable
   - (3) Heard of, unsure how to rate
   - (4) Never heard of it
   - (8) Unsure
   - (9) Refused

```{r DV, D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}

NPR.Aug$BLM020
#
#2. Check the question and the labels 
sjlabelled::get_label(NPR.Aug[,c("BLM020")])   # Values check
sjlabelled::get_labels(NPR.Aug[,c("BLM020")])  # Values check
#
#3. Checking frequencies
table(NPR.Aug$BLM020, useNA = "ifany")                      # Checking frequencies
prop.table(table(NPR.Aug$BLM020, useNA = "ifany"))          # Checking proportions
round(prop.table(table(NPR.Aug$BLM020, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating a new dataset to manipulate variables 
NPR.Aug.final <- NPR.Aug
#
#5. Creating Manipulated DV (BLM_supp) 
NPR.Aug.final$BLM_supp <- NPR.Aug.final$BLM020
#
#6. Selecting options that have data (= removing missing data)
#
NPR.Aug.final <- NPR.Aug.final[NPR.Aug.final$BLM_supp %in% c(1, 2),]
#
#7. Recoding the DV (if necessary)
#
NPR.Aug.final$BLM_supp <- sapply(NPR.Aug.final$BLM_supp,  function(x) 3 - x)


```


### IV - Income

```{r Income, D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}
# 1. checking the variable of interest
#
NPR.Aug.final$INC15WT
#
#2. Checking the question and the labels for the final dataset.. 
sjlabelled::get_label(NPR.Aug.final[,c("INC15WT")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("INC15WT")])  # Values check
#
#3. Checking frequencies 
#
table(NPR.Aug.final$INC15WT, useNA = "ifany")                      # Checking frequencies
prop.table(table(NPR.Aug.final$INC15WT, useNA = "ifany"))          # Checking proportions
round(prop.table(table(NPR.Aug.final$INC15WT, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Aug.final$HIncome <- NPR.Aug.final$INC15WT
#
#5. Selecting options that have data 
#
NPR.Aug.final[NPR.Aug.final$HIncome %in% c(9), "HIncome"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
NPR.Aug.final.meta.income <- NPR.Aug.final[, c("BLM_supp","HIncome")]
#
```

### IV - Age

```{r Age, D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
NPR.Aug.final$AGEEPWT
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(NPR.Aug.final[,c("AGEEPWT")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("AGEEPWT")])  # Values check
#
#3. Checking frequencies 
#
table(NPR.Aug.final$AGEEPWT, useNA = "ifany")                      # Checking frequencies
prop.table(table(NPR.Aug.final$AGEEPWT, useNA = "ifany"))          # Checking proportions
round(prop.table(table(NPR.Aug.final$AGEEPWT, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Aug.final$RAge <- NPR.Aug.final$AGEEPWT
#
#5. Selecting options that have data 
#
NPR.Aug.final[NPR.Aug.final$RAge %in% c(9), "RAge"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
NPR.Aug.final.meta.age <- NPR.Aug.final[, c("BLM_supp","RAge")]
#
```


<br>

### IV - Gender

```{r Gender, D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
NPR.Aug.final$GENDER
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(NPR.Aug.final[,c("GENDER")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("GENDER")])  # Values check
#
#3. Checking frequencies 
#
table(NPR.Aug.final$GENDER, useNA = "ifany")                      # Checking frequencies
prop.table(table(NPR.Aug.final$GENDER, useNA = "ifany"))          # Checking proportions
round(prop.table(table(NPR.Aug.final$GENDER, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Aug.final$RGender <- NPR.Aug.final$GENDER
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
NPR.Aug.final.meta.gender <- NPR.Aug.final[, c("BLM_supp","RGender")]
#
```


<br>


### IV - Education

```{r Education, D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
NPR.Aug.final$COLLEGEP
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Aug.final[,c("COLLEGEP")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("COLLEGEP")])  # Values check
#
#3. Checking frequencies 
#
table(NPR.Aug.final$COLLEGEP, useNA = "ifany")                      # Checking frequencies
prop.table(table(NPR.Aug.final$COLLEGEP, useNA = "ifany"))          # Checking proportions
round(prop.table(table(NPR.Aug.final$COLLEGEP, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Aug.final$REducation <- NPR.Aug.final$COLLEGEP
#
#5. Selecting options that have data 
#
NPR.Aug.final[NPR.Aug.final$REducation %in% c(7, 9), "REducation"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Aug.final.meta.education <- NPR.Aug.final[, c("BLM_supp","REducation")]
#
```

<br>

### IV - Urbanicity

```{r Urbanicity, D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
NPR.Aug.final$USR001
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(NPR.Aug.final[,c("USR001")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("USR001")])  # Values check
#
#3. Checking frequencies 
#
table(NPR.Aug.final$USR001, useNA = "ifany")                      # Checking frequencies
prop.table(table(NPR.Aug.final$USR001, useNA = "ifany"))          # Checking proportions
round(prop.table(table(NPR.Aug.final$USR001, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Aug.final$Urbanicity <- NPR.Aug.final$USR001
#
#5. Selecting options that have data 
NPR.Aug.final[NPR.Aug.final$Urbanicity %in% c(8,9), "Urbanicity"] <- NA
#
#RECODING
NPR.Aug.final$Urbanicity <- sapply(NPR.Aug.final$Urbanicity,  function(x) 6 - x)
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
NPR.Aug.final.meta.urbanicity <- NPR.Aug.final[, c("BLM_supp","Urbanicity")]
#
```

<br>




### IV - Partisanship - Republicans

```{r Partisanship - Republicans, D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Republican
#NPR.Aug$PARTYID
NPR.Aug.final$PARTYID
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Aug.final[,c("PARTYID")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("PARTYID")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Aug.final$PARTYID, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Aug.final$PARTYID, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Aug.final$PARTYID, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Aug.final$Partisanship_Rep <- NPR.Aug.final$PARTYID
#
#5. Selecting options that have data 
#
# NA
NPR.Aug.final[NPR.Aug.final$Partisanship_Rep %in% c(7,9), "Partisanship_Rep"] <- NA
#
#
#6. Recoding the IV (if necessary)
NPR.Aug.final$Partisanship_Rep <- as.numeric(NPR.Aug.final$Partisanship_Rep)
NPR.Aug.final$Partisanship_Rep <- car::recode(NPR.Aug.final$Partisanship_Rep, ' "2"="3"; "3"="2" ')
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Aug.final.meta.partisanshiprep <- NPR.Aug.final[, c("BLM_supp","Partisanship_Rep")]
#
```


<br>





### IV - Vote Intention

```{r Vote Intention, D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#NPR.Aug$CVMLVT20
NPR.Aug.final$CVMLVT20
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Aug.final[,c("CVMLVT20")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("CVMLVT20")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Aug.final$CVMLVT20, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Aug.final$CVMLVT20, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Aug.final$CVMLVT20, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Aug.final$VoteInt <- NPR.Aug.final$CVMLVT20
#
#5. Selecting options that have data 
#
NPR.Aug.final[NPR.Aug.final$VoteInt %in% c(8,9), "VoteInt"] <- NA
#
#6. Recoding the IV (if necessary)
NPR.Aug.final$VoteInt <- sapply(NPR.Aug.final$VoteInt,  function(x) 4 - x)
#
NPR.Aug.final[NPR.Aug.final$VoteInt %in% c(2,3), "VoteInt"] <- 2
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Aug.final.meta.voteint <- NPR.Aug.final[, c("BLM_supp","VoteInt")]
#
```


<br>



### IV - Who would better handle Race Relations: Trump or Biden?

```{r Who would better handle Race Relations: Trump or Biden?, D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#NPR.Aug$DTJBHRR1
NPR.Aug.final$DTJBHRR1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Aug.final[,c("DTJBHRR1")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("DTJBHRR1")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Aug.final$DTJBHRR1, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Aug.final$DTJBHRR1, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Aug.final$DTJBHRR1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Aug.final$BidenvsTrump_Race <- NPR.Aug.final$DTJBHRR1
#
#5. Selecting options that have data 
#
NPR.Aug.final[NPR.Aug.final$BidenvsTrump_Race %in% c(7,8,9), "BidenvsTrump_Race"] <- NA
#
#6. Recoding the IV (if necessary)
NPR.Aug.final$BidenvsTrump_Race <- sapply(NPR.Aug.final$BidenvsTrump_Race,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Aug.final.meta.bidentrump_race <- NPR.Aug.final[, c("BLM_supp","BidenvsTrump_Race")]
#
```


<br>



### IV - Prospective Vote 2020 - Trump VS Biden

```{r Prospective Vote 2020 - Trump VS Biden, D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#NPR.Aug$DTJB2020
NPR.Aug.final$DTJB2020
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Aug.final[,c("DTJB2020")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("DTJB2020")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Aug.final$DTJB2020, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Aug.final$DTJB2020, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Aug.final$DTJB2020, useNA = "ifany")),2) # Checking %s with 2 ecimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Aug.final$Vote2020_TrumpvsBiden <- NPR.Aug.final$DTJB2020
#
#5. Selecting options that have data 
#
#NA + oTHER(7), Undecided(8)
NPR.Aug.final[NPR.Aug.final$Vote2020_TrumpvsBiden %in% c(7, 8, 9), "Vote2020_TrumpvsBiden"] <- NA
#
#6. Recoding the IV (if necessary)
#NPR.Aug.final$PVote20 <- sapply(NPR.Aug.final$PVote20,  function(x) 5 - x)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Aug.final.meta.pvote20 <- NPR.Aug.final[, c("BLM_supp","Vote2020_TrumpvsBiden")]
#
```


<br>


### IV - Trump Approval

```{r Trump Approval, D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#NPR.Aug.final$T
NPR.Aug.final$TRUDP105

#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Aug.final[,c("TRUDP105")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("TRUDP105")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Aug.final$TRUDP105, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Aug.final$TRUDP105, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Aug.final$TRUDP105, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Aug.final$Trump_App <- NPR.Aug.final$TRUDP105
#
#5. Selecting options that have data 
#
NPR.Aug.final[NPR.Aug.final$Trump_App %in% c(8,9), "Trump_App"] <- NA
#
#6. Recoding the IV (if necessary)
#
#
NPR.Aug.final$Trump_App <- sapply(NPR.Aug.final$Trump_App,  function(x) 3 - x)
#     
#
                                                              
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Aug.final.meta.trumpapp <- NPR.Aug.final[, c("BLM_supp","Trump_App")]
#
#table(NPR.Aug.final$TRUMPAPP, useNA = "ifany")                    

#table(NPR.Aug.final$Trump_App, useNA = "ifany")                      

```



### IV - Race - Blacks

```{r Race - Blacks, D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#NPR.Aug$RACET
NPR.Aug.final$RACET
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Aug.final[,c("RACET")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("RACET")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Aug.final$RACET, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Aug.final$RACET, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Aug.final$RACET, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Aug.final$Race_Blacks <- NPR.Aug.final$RACET
#
#5. Selecting options that have data 
#
# NA
NPR.Aug.final[NPR.Aug.final$Race_Blacks %in% c(500, 600, 9300, 9700, 9900), "Race_Blacks"] <- NA
#
# Other races
NPR.Aug.final[NPR.Aug.final$Race_Blacks %in% c(100, 300, 400), "Race_Blacks"] <- 0
#
#Blacks
NPR.Aug.final[NPR.Aug.final$Race_Blacks %in% c(200), "Race_Blacks"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Aug.final.meta.raceblacks <- NPR.Aug.final[, c("BLM_supp","Race_Blacks")]
#
```


<br>



### IV - Race - Whites

```{r Race - Whites, D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#NPR.Aug$RACET
NPR.Aug.final$RACET
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Aug.final[,c("RACET")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("RACET")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Aug.final$RACET, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Aug.final$RACET, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Aug.final$RACET, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Aug.final$Race_Whites <- NPR.Aug.final$RACET
#
#5. Selecting options that have data 
#
# NA
NPR.Aug.final[NPR.Aug.final$Race_Whites %in% c(500, 600, 9300, 9700, 9900), "Race_Whites"] <- NA
#
# Other races
NPR.Aug.final[NPR.Aug.final$Race_Whites %in% c(200, 300, 400), "Race_Whites"] <- 0
#
#Whites
NPR.Aug.final[NPR.Aug.final$Race_Whites %in% c(100), "Race_Whites"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Aug.final.meta.racewhites <- NPR.Aug.final[, c("BLM_supp","Race_Whites")]
#
```


<br>




### IV - Race - Hispanic

```{r Race - Hispanic, D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#NPR.Aug$RACET
NPR.Aug.final$RACET
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Aug.final[,c("RACET")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("RACET")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Aug.final$RACET, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Aug.final$RACET, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Aug.final$RACET, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Aug.final$Race_Hisp <- NPR.Aug.final$RACET
#
#5. Selecting options that have data 
#
# NA
NPR.Aug.final[NPR.Aug.final$Race_Hisp %in% c(500, 600, 9300, 9700, 9900), "Race_Hisp"] <- NA
#
# Other races
NPR.Aug.final[NPR.Aug.final$Race_Hisp %in% c(100, 200, 400), "Race_Hisp"] <- 0
#
#Hisp
NPR.Aug.final[NPR.Aug.final$Race_Hisp %in% c(300), "Race_Hisp"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Aug.final.meta.racehispanic <- NPR.Aug.final[, c("BLM_supp","Race_Hisp")]
#
```


<br>



### IV - Race - Asians

```{r Race - Asians, D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#NPR.Aug$RACET
NPR.Aug.final$RACET
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Aug.final[,c("RACET")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("RACET")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Aug.final$RACET, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Aug.final$RACET, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Aug.final$RACET, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Aug.final$Race_Asians <- NPR.Aug.final$RACET
#
#5. Selecting options that have data 
#
# NA
NPR.Aug.final[NPR.Aug.final$Race_Asians %in% c(500, 600, 9300, 9700, 9900), "Race_Asians"] <- NA
#
# Other races
NPR.Aug.final[NPR.Aug.final$Race_Asians %in% c(100, 200, 300), "Race_Asians"] <- 0
#
#Asians
NPR.Aug.final[NPR.Aug.final$Race_Asians %in% c(400), "Race_Asians"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Aug.final.meta.raceasians <- NPR.Aug.final[, c("BLM_supp","Race_Asians")]
#
```

### IV - Protests Legitimate

```{r Protest Legitimate, D11. NPR PBS News Hour Marist Poll August 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#confident with personal finances - Highest

NPR.Aug.final$PRTSTGF1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Aug.final[,c("PRTSTGF1")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("PRTSTGF1")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Aug.final$PRTSTGF1, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(NPR.Aug.final$PRTSTGF1, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(NPR.Aug.final$PRTSTGF1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Aug.final$Protest_Legit <- NPR.Aug.final$PRTSTGF1
#
#5. Selecting options that have data 
#
NPR.Aug.final[NPR.Aug.final$Protest_Legit %in% c(8, 9), "Protest_Legit"] <- NA
#
#6. Recoding the IV (if necessary)
NPR.Aug.final$Protest_Legit <- sapply(NPR.Aug.final$Protest_Legit,  function(x) 3 - x)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Aug.final.meta.protestlegit <- NPR.Aug.final[, c("BLM_supp","Protest_Legit")]
#
```



<br>






## D12. NPR PBS News Hour Marist Poll September 2020

```{r loading data - D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}


######### PATH L.M. ####################
NPR.Sep <- haven::read_spss("Roper data/NPRPBS NewsHourMarist Poll September 2020/31117708.por")

######### PATH F.A. ####################
# NPR.Sep <- haven::read_spss("C:/Users/Flavio/Dropbox/Tamara/BLM/Roper data/NPRPBS NewsHourMarist Poll September 2020/31117708.por")

######### PATH T.M. ####################
#NPR.Sep <- haven::read_spss("C:/Users/tmmar/Dropbox/Tamara/BLM/Roper data/NPRPBS NewsHourMarist Poll September 2020/31117708.por")


labelled::look_for(NPR.Sep) %>% dplyr::as_tibble() -> NPR.Sep.codebook 

```

### DV

* BLM020. In general, do you have a favorable or unfavorable impression of the Black Lives Matter movement?
   - (1) Favorable
   - (2) Unfavorable
   - (3) Heard of, unsure how to rate
   - (4) Never heard of it
   - (8) Unsure
   - (9) Refused


```{r DV, D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}

NPR.Sep$BLM020
#
#2. Check the question and the labels 
sjlabelled::get_label(NPR.Sep[,c("BLM020")])   # Values check
sjlabelled::get_labels(NPR.Sep[,c("BLM020")])  # Values check
#
#3. Checking frequencies
table(NPR.Sep$BLM020, useNA = "ifany")                      # Checking frequencies
prop.table(table(NPR.Sep$BLM020, useNA = "ifany"))          # Checking proportions
round(prop.table(table(NPR.Sep$BLM020, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating a new dataset to manipulate variables 
NPR.Sep.final <- NPR.Sep
#
#5. Creating Manipulated DV (BLM_supp) 
NPR.Sep.final$BLM_supp <- NPR.Sep.final$BLM020
#
#6. Selecting options that have data (= removing missing data)
#
NPR.Sep.final <- NPR.Sep.final[NPR.Sep.final$BLM_supp %in% c(1, 2),]
#
#7. Recoding the DV (if necessary)
#
NPR.Sep.final$BLM_supp <- sapply(NPR.Sep.final$BLM_supp,  function(x) 3 - x)


```

### IV - Income

```{r Income, D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}
# 1. checking the variable of interest
#
NPR.Sep.final$INC15WT
#
#2. Checking the question and the labels for the final dataset.. 
sjlabelled::get_label(NPR.Aug.final[,c("INC15WT")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("INC15WT")])  # Values check
#
#3. Checking frequencies 
#
table(NPR.Sep.final$INC15WT, useNA = "ifany")                      # Checking frequencies
prop.table(table(NPR.Sep.final$INC15WT, useNA = "ifany"))          # Checking proportions
round(prop.table(table(NPR.Sep.final$INC15WT, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Sep.final$HIncome <- NPR.Sep.final$INC15WT
#
#5. Selecting options that have data 
#
NPR.Sep.final[NPR.Sep.final$HIncome %in% c(9), "HIncome"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
NPR.Sep.final.meta.income <- NPR.Sep.final[, c("BLM_supp","HIncome")]
#
```

### IV - Age

```{r Age, D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
NPR.Sep.final$AGEEPWT
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(NPR.Aug.final[,c("AGEEPWT")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("AGEEPWT")])  # Values check
#
#3. Checking frequencies 
#
table(NPR.Sep.final$AGEEPWT, useNA = "ifany")                      # Checking frequencies
prop.table(table(NPR.Sep.final$AGEEPWT, useNA = "ifany"))          # Checking proportions
round(prop.table(table(NPR.Sep.final$AGEEPWT, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Sep.final$RAge <- NPR.Sep.final$AGEEPWT
#
#5. Selecting options that have data 
#
NPR.Sep.final[NPR.Sep.final$RAge %in% c(9), "RAge"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
NPR.Sep.final.meta.age <- NPR.Sep.final[, c("BLM_supp","RAge")]
#
```

<br>

### IV - Gender

```{r Gender, D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
NPR.Sep.final$GENDER
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(NPR.Aug.final[,c("GENDER")])   # Values check
sjlabelled::get_labels(NPR.Aug.final[,c("GENDER")])  # Values check
#
#3. Checking frequencies 
#
table(NPR.Sep.final$GENDER, useNA = "ifany")                      # Checking frequencies
prop.table(table(NPR.Sep.final$GENDER, useNA = "ifany"))          # Checking proportions
round(prop.table(table(NPR.Sep.final$GENDER, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Sep.final$RGender <- NPR.Sep.final$GENDER
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
NPR.Sep.final.meta.gender <- NPR.Sep.final[, c("BLM_supp","RGender")]
#
```

<br>


### IV - Education

```{r Education, D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
NPR.Sep.final$COLLEGEP
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Sep.final[,c("COLLEGEP")])   # Values check
sjlabelled::get_labels(NPR.Sep.final[,c("COLLEGEP")])  # Values check
#
#3. Checking frequencies 
#
table(NPR.Sep.final$COLLEGEP, useNA = "ifany")                      # Checking frequencies
prop.table(table(NPR.Sep.final$COLLEGEP, useNA = "ifany"))          # Checking proportions
round(prop.table(table(NPR.Sep.final$COLLEGEP, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Sep.final$REducation <- NPR.Sep.final$COLLEGEP
#
#5. Selecting options that have data 
#
NPR.Sep.final[NPR.Sep.final$REducation %in% c(9), "REducation"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Sep.final.meta.education <- NPR.Sep.final[, c("BLM_supp","REducation")]
#
```

<br>


### IV - Urbanicity

```{r Urbanicity, D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
NPR.Sep.final$USR001
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(NPR.Sep.final[,c("USR001")])   # Values check
sjlabelled::get_labels(NPR.Sep.final[,c("USR001")])  # Values check
#
#3. Checking frequencies 
#
table(NPR.Sep.final$USR001, useNA = "ifany")                      # Checking frequencies
prop.table(table(NPR.Sep.final$USR001, useNA = "ifany"))          # Checking proportions
round(prop.table(table(NPR.Sep.final$USR001, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Sep.final$Urbanicity <- NPR.Sep.final$USR001
#
#5. Selecting options that have data 
NPR.Sep.final[NPR.Sep.final$Urbanicity %in% c(8,9), "Urbanicity"] <- NA
#
#RECODING
NPR.Sep.final$Urbanicity <- sapply(NPR.Sep.final$Urbanicity,  function(x) 6 - x)
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
NPR.Sep.final.meta.urbanicity <- NPR.Sep.final[, c("BLM_supp","Urbanicity")]
#
```

<br>


### IV - Partisanship - Republicans

```{r Partisanship - Republicans, D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Republican
#NPR.Sep$PARTYID
NPR.Sep.final$PARTYID
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Sep.final[,c("PARTYID")])   # Values check
sjlabelled::get_labels(NPR.Sep.final[,c("PARTYID")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Sep.final$PARTYID, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Sep.final$PARTYID, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Sep.final$PARTYID, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Sep.final$Partisanship_Rep <- NPR.Sep.final$PARTYID
#
#5. Selecting options that have data 
#
# NA
NPR.Sep.final[NPR.Sep.final$Partisanship_Rep %in% c(7,9), "Partisanship_Rep"] <- NA
#
#
#6. Recoding the IV (if necessary)
NPR.Sep.final$Partisanship_Rep <- as.numeric(NPR.Sep.final$Partisanship_Rep)
NPR.Sep.final$Partisanship_Rep <- car::recode(NPR.Sep.final$Partisanship_Rep, ' "2"="3"; "3"="2" ')
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Sep.final.meta.partisanshiprep <- NPR.Sep.final[, c("BLM_supp","Partisanship_Rep")]
#
```


<br>


### IV - Vote Intention

```{r Vote Intention, D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#NPR.Sep$VTMTDR2
NPR.Sep.final$VTMTDR2
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Sep.final[,c("VTMTDR2")])   # Values check
sjlabelled::get_labels(NPR.Sep.final[,c("VTMTDR2")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Sep.final$VTMTDR2, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Sep.final$VTMTDR2, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Sep.final$VTMTDR2, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Sep.final$VoteInt <- NPR.Sep.final$VTMTDR2
#
#5. Selecting options that have data 
#
NPR.Sep.final[NPR.Sep.final$VoteInt %in% c(8,9), "VoteInt"] <- NA
#
#6. Recoding the IV (if necessary)
NPR.Sep.final$VoteInt <- sapply(NPR.Sep.final$VoteInt,  function(x) 5 - x)
#
NPR.Sep.final[NPR.Sep.final$VoteInt %in% c(2,3,4), "VoteInt"] <- 2
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Sep.final.meta.voteint <- NPR.Sep.final[, c("BLM_supp","VoteInt")]
#
```


<br>


### IV - Who would better handle Race Relations: Trump or Biden?

```{r Who would better handle Race Relations: Trump or Biden?, D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#NPR.Sep$DTJBHRR1
NPR.Sep.final$DTJBHRR1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Sep.final[,c("DTJBHRR1")])   # Values check
sjlabelled::get_labels(NPR.Sep.final[,c("DTJBHRR1")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Sep.final$DTJBHRR1, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Sep.final$DTJBHRR1, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Sep.final$DTJBHRR1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Sep.final$BidenvsTrump_Race <- NPR.Sep.final$DTJBHRR1
#
#5. Selecting options that have data 
#
NPR.Sep.final[NPR.Sep.final$BidenvsTrump_Race %in% c(7,8,9), "BidenvsTrump_Race"] <- NA
#
#6. Recoding the IV (if necessary)
NPR.Sep.final$BidenvsTrump_Race <- sapply(NPR.Sep.final$BidenvsTrump_Race,  function(x) 3 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Sep.final.meta.bidentrump_race <- NPR.Sep.final[, c("BLM_supp","BidenvsTrump_Race")]
#
```


<br>



### IV - Prospective Vote 2020 - Trump VS Biden

```{r Prospective Vote 2020 - Trump VS Biden, D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#NPR.Sep$DTJB2020
NPR.Sep.final$DTJB2020
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Sep.final[,c("DTJB2020")])   # Values check
sjlabelled::get_labels(NPR.Sep.final[,c("DTJB2020")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Sep.final$DTJB2020, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Sep.final$DTJB2020, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Sep.final$DTJB2020, useNA = "ifany")),2) # Checking %s with 2 ecimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Sep.final$Vote2020_TrumpvsBiden <- NPR.Sep.final$DTJB2020
#
#5. Selecting options that have data 
#
#NA + Vol: Jo Jorgensen and Jeremy Spike Cohen, the Libertarians(3), Howie Hawkins and Angela Walker, the Green Party candidates(4), : Kanye West and Michelle Tidball, Independent cand(5)
NPR.Sep.final[NPR.Sep.final$Vote2020_TrumpvsBiden %in% c(3, 4, 5, 7, 8, 9), "Vote2020_TrumpvsBiden"] <- NA
#
#6. Recoding the IV (if necessary)
#NPR.Sep.final$PVote20 <- sapply(NPR.Sep.final$PVote20,  function(x) 5 - x)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Sep.final.meta.pvote20 <- NPR.Sep.final[, c("BLM_supp","Vote2020_TrumpvsBiden")]
#
```


<br>


### IV - Trump Approval

```{r Trump Approval, D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#

NPR.Sep.final$TRUDP1_2

#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Sep.final[,c("TRUDP1_2")])   # Values check
sjlabelled::get_labels(NPR.Sep.final[,c("TRUDP1_2")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Sep.final$TRUDP1_2, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Sep.final$TRUDP1_2, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Sep.final$TRUDP1_2, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Sep.final$Trump_App <- NPR.Sep.final$TRUDP1_2
#
#5. Selecting options that have data 
#
NPR.Sep.final[NPR.Sep.final$Trump_App %in% c(8), "Trump_App"] <- NA
#
#6. Recoding the IV (if necessary)
#
#
NPR.Sep.final$Trump_App <- sapply(NPR.Sep.final$Trump_App,  function(x) 5 - x)
#     
#
                                                              
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Sep.final.meta.trumpapp <- NPR.Aug.final[, c("BLM_supp","Trump_App")]
#
#table(NPR.Aug.final$TRUMPAPP, useNA = "ifany")                    

#table(NPR.Aug.final$Trump_App, useNA = "ifany")                      

```




### IV - Race - Blacks

```{r Race - Blacks, D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#NPR.Sep$RACET
NPR.Sep.final$RACET
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Sep.final[,c("RACET")])   # Values check
sjlabelled::get_labels(NPR.Sep.final[,c("RACET")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Sep.final$RACET, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Sep.final$RACET, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Sep.final$RACET, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Sep.final$Race_Blacks <- NPR.Sep.final$RACET
#
#5. Selecting options that have data 
#
# NA
NPR.Sep.final[NPR.Sep.final$Race_Blacks %in% c(500, 600, 9300, 9700, 9900), "Race_Blacks"] <- NA
#
# Other races
NPR.Sep.final[NPR.Sep.final$Race_Blacks %in% c(100, 300, 400), "Race_Blacks"] <- 0
#
#Blacks
NPR.Sep.final[NPR.Sep.final$Race_Blacks %in% c(200), "Race_Blacks"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Sep.final.meta.raceblacks <- NPR.Sep.final[, c("BLM_supp","Race_Blacks")]
#
```


<br>



### IV - Race - Whites

```{r Race - Whites, D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#NPR.Sep$RACET
NPR.Sep.final$RACET
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Sep.final[,c("RACET")])   # Values check
sjlabelled::get_labels(NPR.Sep.final[,c("RACET")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Sep.final$RACET, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Sep.final$RACET, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Sep.final$RACET, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Sep.final$Race_Whites <- NPR.Sep.final$RACET
#
#5. Selecting options that have data 
#
# NA
NPR.Sep.final[NPR.Sep.final$Race_Whites %in% c(500, 600, 9300, 9700, 9900), "Race_Whites"] <- NA
#
# Other races
NPR.Sep.final[NPR.Sep.final$Race_Whites %in% c(200, 300, 400), "Race_Whites"] <- 0
#
#Whites
NPR.Sep.final[NPR.Sep.final$Race_Whites %in% c(100), "Race_Whites"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Sep.final.meta.racewhites <- NPR.Sep.final[, c("BLM_supp","Race_Whites")]
#
```


<br>




### IV - Race - Hispanic

```{r Race - Hispanic, D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#NPR.Sep$RACET
NPR.Sep.final$RACET
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Sep.final[,c("RACET")])   # Values check
sjlabelled::get_labels(NPR.Sep.final[,c("RACET")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Sep.final$RACET, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Sep.final$RACET, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Sep.final$RACET, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Sep.final$Race_Hisp <- NPR.Sep.final$RACET
#
#5. Selecting options that have data 
#
# NA
NPR.Sep.final[NPR.Sep.final$Race_Hisp %in% c(500, 600, 9300, 9700, 9900), "Race_Hisp"] <- NA
#
# Other races
NPR.Sep.final[NPR.Sep.final$Race_Hisp %in% c(100, 200, 400), "Race_Hisp"] <- 0
#
#Hisp
NPR.Sep.final[NPR.Sep.final$Race_Hisp %in% c(300), "Race_Hisp"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Sep.final.meta.racehispanic <- NPR.Sep.final[, c("BLM_supp","Race_Hisp")]
#
```


<br>



### IV - Race - Asians

```{r Race - Asians, D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#
#NPR.Sep$RACET
NPR.Sep.final$RACET
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Sep.final[,c("RACET")])   # Values check
sjlabelled::get_labels(NPR.Sep.final[,c("RACET")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Sep.final$RACET, useNA = "ifany")                      # Checking frequencies
#prop.table(table(NPR.Sep.final$RACET, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(NPR.Sep.final$RACET, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Sep.final$Race_Asians <- NPR.Sep.final$RACET
#
#5. Selecting options that have data 
#
# NA
NPR.Sep.final[NPR.Sep.final$Race_Asians %in% c(500, 600, 9300, 9700, 9900), "Race_Asians"] <- NA
#
# Other races
NPR.Sep.final[NPR.Sep.final$Race_Asians %in% c(100, 200, 300), "Race_Asians"] <- 0
#
#Asians
NPR.Sep.final[NPR.Sep.final$Race_Asians %in% c(400), "Race_Asians"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Sep.final.meta.raceasians <- NPR.Sep.final[, c("BLM_supp","Race_Asians")]
#
```

### IV - Protests Legitimate

```{r Protest Legitimate, D12. NPR PBS News Hour Marist Poll September 2020, include=FALSE}
# 1. Instructions to check the variable of interest
#confident with personal finances - Highest

NPR.Sep.final$PRTSTGF1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(NPR.Sep.final[,c("PRTSTGF1")])   # Values check
sjlabelled::get_labels(NPR.Sep.final[,c("PRTSTGF1")])  # Values check
#
#3. Checking frequencies 
#
#table(NPR.Sep.final$PRTSTGF1, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(NPR.Sep.final$PRTSTGF1, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(NPR.Sep.final$PRTSTGF1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
NPR.Sep.final$Protest_Legit <- NPR.Sep.final$PRTSTGF1
#
#5. Selecting options that have data 
#
NPR.Sep.final[NPR.Sep.final$Protest_Legit %in% c(8, 9), "Protest_Legit"] <- NA
#
#6. Recoding the IV (if necessary)
NPR.Sep.final$Protest_Legit <- sapply(NPR.Sep.final$Protest_Legit,  function(x) 3 - x)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
NPR.Sep.final.meta.protestlegit <- NPR.Sep.final[, c("BLM_supp","Protest_Legit")]
#
```



<br>


## D13. Pew Research Center 2016 Racial Attitudes in America III

```{r loading data - D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}

######### PATH L.M. ####################
Pew.2016 <- haven::read_spss("Roper data/Pew Research Center 2016 Racial Attitudes in America III/31114971.por")

######### PATH F.A. ####################
# Pew.2016 <- haven::read_spss("C:/Users/Flavio/Dropbox/Tamara/BLM/Roper data/Pew Research Center 2016 Racial Attitudes in America III/31114971.por")

######### PATH T.M. ####################
#Pew.2016 <- haven::read_spss("C:/Users/tmmar/Dropbox/Tamara/BLM/Roper data/Pew Research Center 2016 Racial Attitudes in America III/31114971.por")


labelled::look_for(Pew.2016) %>% dplyr::as_tibble() -> Pew.2016.codebook 

```

### DV

* Q35. From what you've heard, do you strongly support, somewhat support, somewhat oppose, or strongly oppose the Black Lives Matter movement?
   - (1) Strongly support
   - (2) Somewhat support
   - (3) Somewhat oppose
   - (4) Strongly oppose
   - (5) Neither support, nor oppose
   - (9) Don't know/Refused


```{r DV, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}

Pew.2016$Q35
#
#2. Check the question and the labels 
sjlabelled::get_label(Pew.2016[,c("Q35")])   # Values check
sjlabelled::get_labels(Pew.2016[,c("Q35")])  # Values check
#
#3. Checking frequencies
table(Pew.2016$Q35, useNA = "ifany")                      # Checking frequencies
prop.table(table(Pew.2016$Q35, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Pew.2016$Q35, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating a new dataset to manipulate variables 
Pew.2016.final <- Pew.2016
#
#5. Creating Manipulated DV (BLM_supp) 
Pew.2016.final$BLM_supp<- Pew.2016.final$Q35
#
#6. Selecting options that have data (= removing missing data)
#
Pew.2016.final <- Pew.2016.final[Pew.2016.final$BLM_supp %in% c(1, 2, 3, 4, 5),]
#
#7. Recoding the DV (if necessary)
#
# Here, we first need to code answer 5 (Neither support, nor oppose) as the middle point in the scale
Pew.2016.final$BLM_supp <- as.numeric(Pew.2016.final$BLM_supp)
#table(Pew.2016.final$BLM_supp, useNA = "ifany")
Pew.2016.final$BLM_supp <- car::recode(Pew.2016.final$BLM_supp, ' "1"="1"; "2"="2"; "3"="4"; "4"="5"; "5"="3" ')

Pew.2016.final$BLM_supp <- sapply(Pew.2016.final$BLM_supp,  function(x) 6 - x)

```


### IV - Income

```{r Income, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. checking the variable of interest
#
Pew.2016.final$INCOME
#
#2. Checking the question and the labels for the final dataset.. 
sjlabelled::get_label(Pew.2016.final[,c("INCOME")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("INCOME")])  # Values check
#
#3. Checking frequencies 
#
table(Pew.2016.final$INCOME, useNA = "ifany")                      # Checking frequencies
prop.table(table(Pew.2016.final$INCOME, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Pew.2016.final$INCOME, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$HIncome <- Pew.2016.final$INCOME
#
#5. Selecting options that have data 
#
Pew.2016.final[Pew.2016.final$HIncome %in% c(99), "HIncome"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Pew.2016.final.meta.income <- Pew.2016.final[, c("BLM_supp","HIncome")]
#
```

### IV - Age

```{r Age, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.2016.final$AGE
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(Pew.2016.final[,c("AGE")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("AGE")])  # Values check
#
#3. Checking frequencies 
#
table(Pew.2016.final$AGE, useNA = "ifany")                      # Checking frequencies
prop.table(table(Pew.2016.final$AGE, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Pew.2016.final$AGE, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$RAge <- Pew.2016.final$AGE
#
#5. Selecting options that have data 
#
Pew.2016.final[Pew.2016.final$RAge %in% c(99), "RAge"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Pew.2016.final.meta.age <- Pew.2016.final[, c("BLM_supp","RAge")]
#
```


<br>

### IV - Gender

```{r Gender, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.2016.final$SEX
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(Pew.2016.final[,c("SEX")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("SEX")])  # Values check
#
#3. Checking frequencies 
#
table(Pew.2016.final$SEX, useNA = "ifany")                      # Checking frequencies
prop.table(table(Pew.2016.final$SEX, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Pew.2016.final$SEX, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$RGender <- Pew.2016.final$SEX
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Pew.2016.final.meta.gender <- Pew.2016.final[, c("BLM_supp","RGender")]
#
```


<br>


### IV - Education

```{r Education, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.2016.final$EDUC2
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.2016.final[,c("EDUC2")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("EDUC2")])  # Values check
#
#3. Checking frequencies 
#
table(Pew.2016.final$EDUC2, useNA = "ifany")                      # Checking frequencies
prop.table(table(Pew.2016.final$EDUC2, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Pew.2016.final$EDUC2, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$REducation <- Pew.2016.final$EDUC2
#
#5. Selecting options that have data 
#
Pew.2016.final[Pew.2016.final$REducation %in% c(9), "REducation"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.2016.final.meta.education <- Pew.2016.final[, c("BLM_supp","REducation")]
#
```

<br>


### IV - Partisanship - Republicans

```{r Partisanship - Republicans, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Republican
#Pew.2016$PARTY
Pew.2016.final$PARTY
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.2016.final[,c("PARTY")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("PARTY")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.2016.final$PARTY, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.2016.final$PARTY, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.2016.final$PARTY, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$Partisanship_Rep <- Pew.2016.final$PARTY
#
#5. Selecting options that have data 
#
# NA
Pew.2016.final[Pew.2016.final$Partisanship_Rep %in% c(4,5,9), "Partisanship_Rep"] <- NA
#
#6. Recoding the IV (if necessary)
Pew.2016.final$Partisanship_Rep <- as.numeric(Pew.2016.final$Partisanship_Rep)
Pew.2016.final$Partisanship_Rep <- car::recode(Pew.2016.final$Partisanship_Rep, '"2"="1"; "1"="3"; "3"="2" ')
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.2016.final.meta.partisanshiprep <- Pew.2016.final[, c("BLM_supp","Partisanship_Rep")]
#
```


<br>


### IV - Ideology

```{r Ideology, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.2016.final$IDEO
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.2016.final[,c("IDEO")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("IDEO")])  # Values check
#
#3. Checking frequencies 
#table(Pew.2016.final$IDEO, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.2016.final$IDEO, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.2016.final$IDEO, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$Ideol_Conservative <- Pew.2016.final$IDEO
#
#5. Selecting options that have data 
#
Pew.2016.final[Pew.2016.final$Ideol_Conservative %in% c(9), "Ideol_Conservative"] <- NA
#
#
#6. Recoding the IV (if necessary)

# 1 Liberal (or); 2 Very liberal
Pew.2016.final[Pew.2016.final$Ideol_Conservative %in% c(1,2), "Ideol_Conservative"] <- 1
#3 Moderate
Pew.2016.final[Pew.2016.final$Ideol_Conservative %in% c(3), "Ideol_Conservative"] <- 2
#4 Very conservative (or); 5 Conservative
Pew.2016.final[Pew.2016.final$Ideol_Conservative %in% c(4,5), "Ideol_Conservative"] <- 3

Pew.2016.final$Ideol_Conservative <- sapply(Pew.2016.final$Ideol_Conservative,  function(x) 4 - x)


#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.2016.final.meta.ideology <- Pew.2016.final[, c("BLM_supp","Ideol_Conservative")]
#
```


<br>



### IV - Religiosity

```{r Religiosity, D13. Pew Research Center 2016 Racial Attitudes in America II, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.2016$RELIG
Pew.2016.final$RELIG
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.2016.final[,c("RELIG")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("RELIG")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.2016.final$RELIG, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.2016.final$RELIG, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.2016.final$RELIG, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$Religiosity <- Pew.2016.final$RELIG
#
#5. Selecting options that have data 
#
Pew.2016.final[Pew.2016.final$Religiosity %in% c(99), "Religiosity"] <- NA
#
#6. Recoding the IV (if necessary)
#Pew.2016.final$Religiosity <- sapply(Pew.2016.final$Religiosity,  function(x) 15 - x)
#
Pew.2016.final$Religiosity <- as.numeric(Pew.2016.final$Religiosity)
Pew.2016.final$Religiosity <- car::recode(Pew.2016.final$Religiosity, ' "2"="1"; "3"="1"; "4"="1"; "5"="1"; "6"="1"; "7"="1";"8"="1"; "11"="1"; "13"="1";"14"="1"; "9"="0"; "10"="0";"12"="0" ')

#Pew.2016.final[Pew.2016.final$Religiosity %in% c(1,2,3,4,5,6,7,8,11,13,14), "Religiosity"] <- 1
#Pew.2016.final[Pew.2016.final$Religiosity %in% c(9,10,12), "Religiosity"] <- 0
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.2016.final.meta.religiosity <- Pew.2016.final[, c("BLM_supp","Religiosity")]
#
```


<br>


### IV - Registered to Vote

```{r Registered to Vote, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.2016$REG
Pew.2016.final$REG
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.2016.final[,c("REG")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("REG")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.2016.final$REG, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.2016.final$REG, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.2016.final$REG, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$VoteReg <- Pew.2016.final$REG
#
#5. Selecting options that have data 
#
Pew.2016.final[Pew.2016.final$VoteReg %in% c(2, 9), "VoteReg"] <- NA

#Changing option 3 to 2, so the scale is linear
Pew.2016.final[Pew.2016.final$VoteReg %in% c(3), "VoteReg"] <- 2
#
#6. Recoding the IV (if necessary)
Pew.2016.final$VoteReg <- sapply(Pew.2016.final$VoteReg,  function(x) 3 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.2016.final.meta.votereg <- Pew.2016.final[, c("BLM_supp","VoteReg")]
#
```


<br>



### IV - Race Relations - Better/Worse

```{r Race Relations, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. Instructions to check the variable of interest
#Better- Highest
#Pew.2016$Q5AF1
Pew.2016.final$Q5AF1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.2016.final[,c("Q5AF1")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("Q5AF1")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.2016.final$Q5AF1, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(Pew.2016.final$Q5AF1, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Pew.2016.final$Q5AF1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$RaceRelations_Better <- Pew.2016.final$Q5AF1
#
#5. Selecting options that have data 
#
Pew.2016.final[Pew.2016.final$RaceRelations_Better %in% c(9), "RaceRelations_Better"] <- NA
#
#6. Recoding the IV (if necessary)
#Pew.2016.final$RaceRelations <- sapply(Pew.2016.final$RaceRelations,  function(x) 3 - x)
Pew.2016.final$RaceRelations_Better <- as.numeric(Pew.2016.final$RaceRelations_Better)
Pew.2016.final$RaceRelations_Better <- car::recode(Pew.2016.final$RaceRelations_Better, ' "1"="3"; "2"="1"; "3"="2" ')
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.2016.final.meta.racerelationsbetter <- Pew.2016.final[, c("BLM_supp","RaceRelations_Better")]
#
```


<br>


### IV - Perceptions on racial discrimination (against Blacks)

```{r Racial discrimination (against Blacks), D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.2016.final$Q19AF2
Pew.2016.final$Q19BF2
Pew.2016.final$Q19CF2
Pew.2016.final$Q19DF2
Pew.2016.final$Q19EF2
Pew.2016.final$Q19FF2
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.2016.final[,c("Q19AF2")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("Q19AF2")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.2016.final$Q19AF2, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.2016.final$Q19AF2, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.2016.final$Q19AF2, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$RacialDisc.A <- Pew.2016.final$Q19AF2
Pew.2016.final$RacialDisc.B <- Pew.2016.final$Q19BF2
Pew.2016.final$RacialDisc.C <- Pew.2016.final$Q19CF2
Pew.2016.final$RacialDisc.D <- Pew.2016.final$Q19DF2
Pew.2016.final$RacialDisc.E <- Pew.2016.final$Q19EF2
Pew.2016.final$RacialDisc.F <- Pew.2016.final$Q19FF2
#
#5. Selecting options that have data 
#
Pew.2016.final[Pew.2016.final$RacialDisc.A %in% c(9), "RacialDisc.A"] <- NA
Pew.2016.final[Pew.2016.final$RacialDisc.B %in% c(9), "RacialDisc.B"] <- NA
Pew.2016.final[Pew.2016.final$RacialDisc.C %in% c(9), "RacialDisc.C"] <- NA
Pew.2016.final[Pew.2016.final$RacialDisc.D %in% c(9), "RacialDisc.D"] <- NA
Pew.2016.final[Pew.2016.final$RacialDisc.E %in% c(9), "RacialDisc.E"] <- NA
Pew.2016.final[Pew.2016.final$RacialDisc.F %in% c(9), "RacialDisc.F"] <- NA
#

#6. Recoding the IV (if necessary)
#
Pew.2016.final$RacialDisc.A.rec <- Pew.2016.final$RacialDisc.A
Pew.2016.final[Pew.2016.final$RacialDisc.A.rec %in% c(2,3), "RacialDisc.A.rec"] <- 0
#
Pew.2016.final$RacialDisc.B.rec <- Pew.2016.final$RacialDisc.B
Pew.2016.final[Pew.2016.final$RacialDisc.B.rec %in% c(2,3), "RacialDisc.B.rec"] <- 0
# 
Pew.2016.final$RacialDisc.C.rec <- Pew.2016.final$RacialDisc.C
Pew.2016.final[Pew.2016.final$RacialDisc.C.rec %in% c(2,3), "RacialDisc.C.rec"] <- 0
#
# 
Pew.2016.final$RacialDisc.D.rec <- Pew.2016.final$RacialDisc.D
Pew.2016.final[Pew.2016.final$RacialDisc.D.rec %in% c(2,3), "RacialDisc.D.rec"] <- 0
# 
Pew.2016.final$RacialDisc.E.rec <- Pew.2016.final$RacialDisc.E
Pew.2016.final[Pew.2016.final$RacialDisc.E.rec %in% c(2,3), "RacialDisc.E.rec"] <- 0
#
# 
Pew.2016.final$RacialDisc.F.rec <- Pew.2016.final$RacialDisc.F
Pew.2016.final[Pew.2016.final$RacialDisc.F.rec %in% c(2,3), "RacialDisc.F.rec"] <- 0
#
#
# Averaging the variables
Pew.2016.final$RacialDisc <- rowMeans(Pew.2016.final[ , c("RacialDisc.A.rec", "RacialDisc.B.rec", "RacialDisc.C.rec", "RacialDisc.D.rec", "RacialDisc.E.rec", "RacialDisc.F.rec")], na.rm=TRUE)
#?rowMeans
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.2016.final.meta.racialdisc <- Pew.2016.final[, c("BLM_supp","RacialDisc")]
#
```




### IV - Personal experience with discrimination

```{r Personal discrimination, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.2016.final$Q27
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.2016.final[,c("Q27")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("Q27")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.2016.final$Q27, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.2016.final$Q27, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.2016.final$Q27, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$PersDiscr <- Pew.2016.final$Q27

#
#5. Selecting options that have data 
#
Pew.2016.final[Pew.2016.final$PersDiscr %in% c(9), "PersDiscr"] <- NA

#
#6. Recoding the IV (if necessary)
#
Pew.2016.final$PersDiscr <- sapply(Pew.2016.final$PersDiscr,  function(x) 5 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.2016.final.meta.persdiscr <- Pew.2016.final[, c("BLM_supp","PersDiscr")]
#
```





### IV - Marital Status

```{r Marital Status, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Married
#Pew.2016$MARITAL
Pew.2016.final$MARITAL
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.2016.final[,c("MARITAL")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("MARITAL")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.2016.final$MARITAL, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.2016.final$MARITAL, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.2016.final$MARITAL, useNA = "ifany")),2) # Checking %s with 2 decimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$MaritalStatus <- Pew.2016.final$MARITAL
#
#5. Selecting options that have data 
#
# NA
Pew.2016.final[Pew.2016.final$MaritalStatus %in% c(2,3,4,5,9), "MaritalStatus"] <- NA
#
# Never been Married
Pew.2016.final[Pew.2016.final$MaritalStatus %in% c(6), "MaritalStatus"] <- 0
#
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.2016.final.meta.maritalstatus <- Pew.2016.final[, c("BLM_supp","MaritalStatus")]
#
```


<br>



### IV - Employment Status

```{r Employment Status, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Employed
#Pew.2016$QE3
Pew.2016.final$QE3
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.2016.final[,c("QE3")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("QE3")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.2016.final$QE3, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.2016.final$QE3, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.2016.final$QE3, useNA = "ifany")),2) # Checking %s with 2 ecimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$EmploymentStatus <- Pew.2016.final$QE3
#
#
#5. Selecting options that have data 
#
# NA
Pew.2016.final[Pew.2016.final$EmploymentStatus %in% c(3,4,9), "EmploymentStatus"] <- NA
#
# Working
Pew.2016.final[Pew.2016.final$EmploymentStatus %in% c(1,2), "EmploymentStatus"] <- 1
#
# Retired
Pew.2016.final[Pew.2016.final$EmploymentStatus %in% c(5), "EmploymentStatus"] <- 0
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.2016.final.meta.employmentstatus <- Pew.2016.final[, c("BLM_supp","EmploymentStatus")]
#
```


<br>



### IV - Race - Blacks

```{r Race - Blacks, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.2016$RACETHN
Pew.2016.final$RACETHN
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.2016.final[,c("RACETHN")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("RACETHN")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.2016.final$RACETHN, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.2016.final$RACETHN, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.2016.final$RACETHN, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$Race_Blacks <- Pew.2016.final$RACETHN
#
#5. Selecting options that have data 
#
# NA
Pew.2016.final[Pew.2016.final$Race_Blacks %in% c(4,9), "Race_Blacks"] <- NA
#
# Other races
Pew.2016.final[Pew.2016.final$Race_Blacks %in% c(1,3), "Race_Blacks"] <- 0
#
#Blacks
Pew.2016.final[Pew.2016.final$Race_Blacks %in% c(2), "Race_Blacks"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.2016.final.meta.raceblacks <- Pew.2016.final[, c("BLM_supp","Race_Blacks")]
#
```


<br>




### IV - Race - Whites

```{r Race - Whites, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.2016$RACETHN
Pew.2016.final$RACETHN
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.2016.final[,c("RACETHN")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("RACETHN")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.2016.final$RACETHN, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.2016.final$RACETHN, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.2016.final$RACETHN, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$Race_Whites <- Pew.2016.final$RACETHN
#
#5. Selecting options that have data 
#
# NA
Pew.2016.final[Pew.2016.final$Race_Whites %in% c(4,9), "Race_Whites"] <- NA
#
# Other races
Pew.2016.final[Pew.2016.final$Race_Whites %in% c(2,3), "Race_Whites"] <- 0
#
#Whites
#Pew.2016.final[Pew.2016.final$Race_Whites %in% c(1), "Race_Whites"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.2016.final.meta.racewhites <- Pew.2016.final[, c("BLM_supp","Race_Whites")]
#
```


<br>


### IV - Race - Hispanic

```{r Race - Hispanic, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.2016$RACETHN
Pew.2016.final$RACETHN
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.2016.final[,c("RACETHN")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("RACETHN")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.2016.final$RACETHN, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.2016.final$RACETHN, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.2016.final$RACETHN, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$Race_Hisp <- Pew.2016.final$RACETHN
#
#5. Selecting options that have data 
#
# NA
Pew.2016.final[Pew.2016.final$Race_Hisp %in% c(4,9), "Race_Hisp"] <- NA
#
# Other races
Pew.2016.final[Pew.2016.final$Race_Hisp %in% c(1,2), "Race_Hisp"] <- 0
#
#Hisp
Pew.2016.final[Pew.2016.final$Race_Hisp %in% c(3), "Race_Hisp"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.2016.final.meta.racehispanic <- Pew.2016.final[, c("BLM_supp","Race_Hisp")]
#
```


<br>



### IV - Systematic Racism

```{r Systematic Racism, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.2016.final$Q42
Pew.2016.final$Q42
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.2016.final[,c("Q42")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("Q42")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.2016.final$Q42, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(Pew.2016.final$Q42, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Pew.2016.final$Q42, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$SystematicRacism <- Pew.2016.final$Q42
#
#5. Selecting options that have data 
#
Pew.2016.final[Pew.2016.final$SystematicRacism %in% c(9), "SystematicRacism"] <- NA
#
Pew.2016.final$SystematicRacism <- as.numeric(Pew.2016.final$SystematicRacism)
Pew.2016.final$SystematicRacism <- car::recode(Pew.2016.final$SystematicRacism, ' "4"="0"; "2"="1"; "3"="2"; "1"="2" ')
#
#6. Recoding the IV (if necessary)
#Pew.2016.final$SystematicRacism <- sapply(Pew.2016.final$SystematicRacism,  function(x) 3 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.2016.final.meta.systematicracism <- Pew.2016.final[, c("BLM_supp","SystematicRacism")]
#

###Trying another variable
Pew.2016.final$Q24BF1
table(Pew.2016.final$Q24BF1, useNA = "ifany") 
Pew.2016.final$SystematicRacism <- Pew.2016.final$Q24BF1
Pew.2016.final[Pew.2016.final$SystematicRacism %in% c(9), "SystematicRacism"] <- NA
Pew.2016.final$SystematicRacism <- sapply(Pew.2016.final$SystematicRacism,  function(x) 4 - x)
Pew.2016.final.meta.systematicracism <- Pew.2016.final[, c("BLM_supp","SystematicRacism")]

```


<br>



### IV - Personal Finances

```{r Personal Finances, D13. Pew Research Center 2016 Racial Attitudes in America III, include=FALSE}
# 1. Instructions to check the variable of interest
#confident with personal finances - Highest
#Pew.2016$Q2C
Pew.2016.final$Q2C
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.2016.final[,c("Q2C")])   # Values check
sjlabelled::get_labels(Pew.2016.final[,c("Q2C")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.2016.final$Q2C, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(Pew.2016.final$Q2C, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Pew.2016.final$Q2C, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.2016.final$Pers_Finances <- Pew.2016.final$Q2C
#
#5. Selecting options that have data 
#
Pew.2016.final[Pew.2016.final$Pers_Finances %in% c(5, 9), "Pers_Finances"] <- NA
#
#6. Recoding the IV (if necessary)
Pew.2016.final$Pers_Finances <- sapply(Pew.2016.final$Pers_Finances,  function(x) 5 - x)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.2016.final.meta.persfinances <- Pew.2016.final[, c("BLM_supp","Pers_Finances")]
#

```


<br>





## D14. Pew Research Center American Trends Panel Wave 22
 
```{r loading data - D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}

######### PATH L.M. ####################
Pew.W22 <- haven::read_spss("Roper data/Pew Research Center American Trends Panel Wave 22/31114184.por")

######### PATH F.A. ####################
# Pew.W22 <- haven::read_spss("C:/Users/Flavio/Dropbox/Tamara/BLM/Roper data/Pew Research Center American Trends Panel Wave 22/31114184.por")

######### PATH T.M. ####################
#Pew.W22 <- haven::read_spss("C:/Users/tmmar/Dropbox/Tamara/BLM/Roper data/Pew Research Center American Trends Panel Wave 22/31114184.por")


labelled::look_for(Pew.W22) %>% dplyr::as_tibble() -> Pew.W22.codebook 

```

### DV

* MESUM2_D. Supporter of the Black Lives Matter movement (Which of these describes you well?)
   - (1) Supporter of the Black Lives Matter Movement
   - (99) Refused

(The data has 0s and 1s, so based on the pdf notes of this dataset, we are asusming that 1 means support, 0 means no support)
  
```{r DV, D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}

Pew.W22$MESUM2_D
#
#2. Check the question and the labels 
sjlabelled::get_label(Pew.W22[,c("MESUM2_D")])   # Values check
sjlabelled::get_labels(Pew.W22[,c("MESUM2_D")])  # Values check
#
#3. Checking frequencies
table(Pew.W22$MESUM2_D, useNA = "ifany")                      # Checking frequencies
prop.table(table(Pew.W22$MESUM2_D, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Pew.W22$MESUM2_D, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating a new dataset to manipulate variables 
Pew.W22.final <- Pew.W22
#
#5. Creating Manipulated DV (BLM_supp) 
Pew.W22.final$BLM_supp <- Pew.W22.final$MESUM2_D
#
#6. Selecting options that have data (= removing missing data)
#
Pew.W22.final <- Pew.W22.final[Pew.W22.final$BLM_supp %in% c(0, 1),]
#
#7. Recoding the DV (if necessary)
#not necessary here, because the larger value is for BLM support



```

### IV - Income

```{r Income, D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}
# 1. checking the variable of interest
#
Pew.W22.final$F_INCOME
#
#2. Checking the question and the labels for the final dataset.. 
sjlabelled::get_label(Pew.W22.final[,c("F_INCOME")])   # Values check
sjlabelled::get_labels(Pew.W22.final[,c("F_INCOME")])  # Values check
#
#3. Checking frequencies 
#
table(Pew.W22.final$F_INCOME, useNA = "ifany")                      # Checking frequencies
prop.table(table(Pew.W22.final$F_INCOME, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Pew.W22.final$F_INCOME, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W22.final$HIncome <- Pew.W22.final$F_INCOME
#
#5. Selecting options that have data 
#
Pew.W22.final[Pew.W22.final$HIncome %in% c(99), "HIncome"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Pew.W22.final.meta.income <- Pew.W22.final[, c("BLM_supp","HIncome")]
#
```

### IV - Age

```{r Age, D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.W22.final$F_AGECAT
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(Pew.W22.final[,c("F_AGECAT")])   # Values check
sjlabelled::get_labels(Pew.W22.final[,c("F_AGECAT")])  # Values check
#
#3. Checking frequencies 
#
table(Pew.W22.final$F_AGECAT, useNA = "ifany")                      # Checking frequencies
prop.table(table(Pew.W22.final$F_AGECAT, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Pew.W22.final$F_AGECAT, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W22.final$RAge <- Pew.W22.final$F_AGECAT
#
#5. Selecting options that have data 
#
#Pew.W22.final[Pew.W22.final$RAge %in% c(NA), "RAge"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Pew.W22.final.meta.age <- Pew.W22.final[, c("BLM_supp","RAge")]
#
```


<br>

### IV - Gender

```{r Gender, D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.W22.final$F_SEX_FI
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(Pew.W22.final[,c("F_SEX_FI")])   # Values check
sjlabelled::get_labels(Pew.W22.final[,c("F_SEX_FI")])  # Values check
#
#3. Checking frequencies 
#
table(Pew.W22.final$F_SEX_FI, useNA = "ifany")                      # Checking frequencies
prop.table(table(Pew.W22.final$F_SEX_FI, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Pew.W22.final$F_SEX_FI, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W22.final$RGender <- Pew.W22.final$F_SEX_FI
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Pew.W22.final.meta.gender <- Pew.W22.final[, c("BLM_supp","RGender")]
#
```


<br>



### IV - Education

```{r Education, D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.W22.final$F_EDUC_1
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W22.final[,c("F_EDUC_1")])   # Values check
sjlabelled::get_labels(Pew.W22.final[,c("F_EDUC_1")])  # Values check
#
#3. Checking frequencies 
#
table(Pew.W22.final$F_EDUC_1, useNA = "ifany")                      # Checking frequencies
prop.table(table(Pew.W22.final$F_EDUC_1, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Pew.W22.final$F_EDUC_1, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W22.final$REducation <- Pew.W22.final$F_EDUC_1
#
#5. Selecting options that have data 
#
#Pew.W22.final[Pew.W22.final$REducation %in% c(9), "REducation"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W22.final.meta.education <- Pew.W22.final[, c("BLM_supp","REducation")]
#
```


### IV - Partisanship - Republicans

```{r Partisanship - Republicans, D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Republican
#Pew.W22$F_PARTY_
Pew.W22.final$F_PARTY_
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W22.final[,c("F_PARTY_")])   # Values check
sjlabelled::get_labels(Pew.W22.final[,c("F_PARTY_")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W22.final$F_PARTY_, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W22.final$F_PARTY_, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W22.final$F_PARTY_, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W22.final$Partisanship_Rep <- Pew.W22.final$F_PARTY_
#
#5. Selecting options that have data 
#
# NA
Pew.W22.final[Pew.W22.final$Partisanship_Rep %in% c(4,99), "Partisanship_Rep"] <- NA
#
#6. Recoding the IV (if necessary)
Pew.W22.final$Partisanship_Rep <- as.numeric(Pew.W22.final$Partisanship_Rep)
Pew.W22.final$Partisanship_Rep <- car::recode(Pew.W22.final$Partisanship_Rep, '"2"="1"; "1"="3"; "3"="2" ')
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W22.final.meta.partisanshiprep <- Pew.W22.final[, c("BLM_supp","Partisanship_Rep")]
#
```


<br>



### IV - Ideology

```{r Ideology, D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.W22$F_IDEO_F
Pew.W22.final$F_IDEO_F
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W22.final[,c("F_IDEO_F")])   # Values check
sjlabelled::get_labels(Pew.W22.final[,c("F_IDEO_F")])  # Values check
#
#3. Checking frequencies 
#table(Pew.W22.final$F_IDEO_F, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W22.final$F_IDEO_F, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W22.final$F_IDEO_F, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W22.final$Ideol_Conservative <- Pew.W22.final$F_IDEO_F
#
#5. Selecting options that have data 
#
Pew.W22.final[Pew.W22.final$Ideol_Conservative %in% c(99), "Ideol_Conservative"] <- NA
#
#
#6. Recoding the IV (if necessary)


# 1 Liberal (or); 2 Very liberal
Pew.W22.final[Pew.W22.final$Ideol_Conservative %in% c(1,2), "Ideol_Conservative"] <- 1
#3 Moderate
Pew.W22.final[Pew.W22.final$Ideol_Conservative %in% c(3), "Ideol_Conservative"] <- 2
#4 Very conservative (or); 5 Conservative
Pew.W22.final[Pew.W22.final$Ideol_Conservative %in% c(4,5), "Ideol_Conservative"] <- 3

Pew.W22.final$Ideol_Conservative <- sapply(Pew.W22.final$Ideol_Conservative,  function(x) 4 - x)

#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W22.final.meta.ideology <- Pew.W22.final[, c("BLM_supp","Ideol_Conservative")]
#
```


<br>


### IV - Religiosity

```{r Religiosity, D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.W22$F_RELIG_
Pew.W22.final$F_RELIG_
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W22.final[,c("F_RELIG_")])   # Values check
sjlabelled::get_labels(Pew.W22.final[,c("F_RELIG_")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W22.final$F_RELIG_, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W22.final$F_RELIG_, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W22.final$F_RELIG_, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W22.final$Religiosity <- Pew.W22.final$F_RELIG_
#
#5. Selecting options that have data 
#
Pew.W22.final[Pew.W22.final$Religiosity %in% c(99), "Religiosity"] <- NA
#
#6. Recoding the IV (if necessary)
#Pew.W22.final$Religiosity <- sapply(Pew.W22.final$Religiosity,  function(x) 15 - x)
#
Pew.W22.final[Pew.W22.final$Religiosity %in% c(1,2,3,4,5,6,7,8,11,13,14), "Religiosity"] <- 1
Pew.W22.final[Pew.W22.final$Religiosity %in% c(9,10,12), "Religiosity"] <- 0
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W22.final.meta.religiosity <- Pew.W22.final[, c("BLM_supp","Religiosity")]
#
```


<br>



### IV - Vote Intention

```{r Vote Intention, D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.W22$PLAN1_W2
Pew.W22.final$PLAN1_W2
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W22.final[,c("PLAN1_W2")])   # Values check
sjlabelled::get_labels(Pew.W22.final[,c("PLAN1_W2")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W22.final$PLAN1_W2, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W22.final$PLAN1_W2, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W22.final$PLAN1_W2, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W22.final$VoteInt <- Pew.W22.final$PLAN1_W2
#
#5. Selecting options that have data 
#
Pew.W22.final[Pew.W22.final$VoteInt %in% c(99), "VoteInt"] <- NA
#
#6. Recoding the IV (if necessary)
Pew.W22.final$VoteInt <- sapply(Pew.W22.final$VoteInt,  function(x) 4 - x)
#
Pew.W22.final[Pew.W22.final$VoteInt %in% c(2,3), "VoteInt"] <- 2
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W22.final.meta.voteint <- Pew.W22.final[, c("BLM_supp","VoteInt")]
#
```


<br>


### IV - Vote 2016 - Clinton VS Trump

```{r Vote 2016 - Clinton VS Trump, D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}
# 1. Instructions to check the variable of interest
#
# Vote for Trump
#Pew.W22$VOTEGENA
Pew.W22.final$VOTEGENA
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W22.final[,c("VOTEGENA")])   # Values check
sjlabelled::get_labels(Pew.W22.final[,c("VOTEGENA")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W22.final$VOTEGENA, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W22.final$VOTEGENA, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W22.final$VOTEGENA, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W22.final$Vote16_ClintonVSTrump <- Pew.W22.final$VOTEGENA
#
#5. Selecting options that have data 
#

Pew.W22.final[Pew.W22.final$Vote16_ClintonVSTrump %in% c(2), "Vote16_ClintonVSTrump"] <- 0
Pew.W22.final[Pew.W22.final$Vote16_ClintonVSTrump %in% c(3,4,5,99), "Vote16_ClintonVSTrump"] <- NA
#
#6. Recoding the IV (if necessary)
#
#Pew.W22.final$Vote16_Hillary <- sapply(Pew.W22.final$Vote16_Hillary,  function(x) 3 - x)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W22.final.meta.vote16clintonvstrump <- Pew.W22.final[, c("BLM_supp","Vote16_ClintonVSTrump")]
#
```


<br>




### IV - Race Relations - Better/Worse

```{r Race Relations, D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}
# 1. Instructions to check the variable of interest
#Better- Highest
Pew.W22.final$EGHTYRSF
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W22.final[,c("EGHTYRSF")])   # Values check
sjlabelled::get_labels(Pew.W22.final[,c("EGHTYRSF")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W22.final$EGHTYRSF, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(Pew.W22.final$EGHTYRSF, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Pew.W22.final$EGHTYRSF, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W22.final$RaceRelations_Better <- Pew.W22.final$EGHTYRSF
#
#5. Selecting options that have data 
#
Pew.W22.final[Pew.W22.final$RaceRelations_Better %in% c(99), "RaceRelations_Better"] <- NA
#
#6. Recoding the IV (if necessary)
#Pew.W22.final$RaceRelations <- sapply(Pew.W22.final$RaceRelations,  function(x) 3 - x)
Pew.W22.final$RaceRelations_Better <- as.numeric(Pew.W22.final$RaceRelations_Better)
Pew.W22.final$RaceRelations_Better <- car::recode(Pew.W22.final$RaceRelations_Better, ' "1"="3"; "2"="1"; "3"="2" ')
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W22.final.meta.racerelationsbetter <- Pew.W22.final[, c("BLM_supp","RaceRelations_Better")]
#
```


<br>




### IV - Race - Blacks

```{r Race - Blacks, D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.W22$F_RACETH
Pew.W22.final$F_RACETH
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W22.final[,c("F_RACETH")])   # Values check
sjlabelled::get_labels(Pew.W22.final[,c("F_RACETH")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W22.final$F_RACETH, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W22.final$F_RACETH, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W22.final$F_RACETH, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W22.final$Race_Blacks <- Pew.W22.final$F_RACETH
#
#5. Selecting options that have data 
#
# NA
Pew.W22.final[Pew.W22.final$Race_Blacks %in% c(4,9), "Race_Blacks"] <- NA
#
# Other races
Pew.W22.final[Pew.W22.final$Race_Blacks %in% c(1,3), "Race_Blacks"] <- 0
#
#Blacks
Pew.W22.final[Pew.W22.final$Race_Blacks %in% c(2), "Race_Blacks"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W22.final.meta.raceblacks <- Pew.W22.final[, c("BLM_supp","Race_Blacks")]
#
```


<br>


### IV - Race - Whites

```{r Race - Whites, D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.W22$F_RACETH
Pew.W22.final$F_RACETH
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W22.final[,c("F_RACETH")])   # Values check
sjlabelled::get_labels(Pew.W22.final[,c("F_RACETH")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W22.final$F_RACETH, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W22.final$F_RACETH, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W22.final$F_RACETH, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W22.final$Race_Whites <- Pew.W22.final$F_RACETH
#
#5. Selecting options that have data 
#
# NA
Pew.W22.final[Pew.W22.final$Race_Whites %in% c(4,9), "Race_Whites"] <- NA
#
# Other races
Pew.W22.final[Pew.W22.final$Race_Whites %in% c(2,3), "Race_Whites"] <- 0
#
#Whites
#Pew.W22.final[Pew.W22.final$Race_Whites %in% c(1), "Race_Whites"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W22.final.meta.racewhites <- Pew.W22.final[, c("BLM_supp","Race_Whites")]
#
```


<br>



### IV - Race - Hispanic

```{r Race - Hispanic, D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.W22$F_RACETH
Pew.W22.final$F_RACETH
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W22.final[,c("F_RACETH")])   # Values check
sjlabelled::get_labels(Pew.W22.final[,c("F_RACETH")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W22.final$F_RACETH, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W22.final$F_RACETH, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W22.final$F_RACETH, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W22.final$Race_Hisp <- Pew.W22.final$F_RACETH
#
#5. Selecting options that have data 
#
# NA
Pew.W22.final[Pew.W22.final$Race_Hisp %in% c(4,9), "Race_Hisp"] <- NA
#
# Other races
Pew.W22.final[Pew.W22.final$Race_Hisp %in% c(1,2), "Race_Hisp"] <- 0
#
#Hisp
Pew.W22.final[Pew.W22.final$Race_Hisp %in% c(3), "Race_Hisp"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W22.final.meta.racehispanic <- Pew.W22.final[, c("BLM_supp","Race_Hisp")]
#
```


<br>

### IV - Personal Finances

```{r Personal Finances, D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}
# 1. Instructions to check the variable of interest
#confident with personal finances - Highest
#Pew.W22$PERSNFIN
Pew.W22.final$PERSNFIN
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W22.final[,c("PERSNFIN")])   # Values check
sjlabelled::get_labels(Pew.W22.final[,c("PERSNFIN")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W22.final$PERSNFIN, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(Pew.W22.final$PERSNFIN, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Pew.W22.final$PERSNFIN, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W22.final$Pers_Finances <- Pew.W22.final$PERSNFIN
#
#5. Selecting options that have data 
#
Pew.W22.final[Pew.W22.final$Pers_Finances %in% c(99), "Pers_Finances"] <- NA
#
#6. Recoding the IV (if necessary)
Pew.W22.final$Pers_Finances <- sapply(Pew.W22.final$Pers_Finances,  function(x) 3 - x)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W22.final.meta.persfinances <- Pew.W22.final[, c("BLM_supp","Pers_Finances")]
#
```


<br>


### IV - Country Economy

```{r Country Economy, D14. Pew Research Center American Trends Panel Wave 22, include=FALSE}
# 1. Instructions to check the variable of interest
#
#CBS.2016$TRACK
Pew.W22.final$ECON1_W2
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W22.final[,c("ECON1_W2")])   # Values check
sjlabelled::get_labels(Pew.W22.final[,c("ECON1_W2")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W22.final$ECON1_W2, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W22.final$ECON1_W2, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W22.final$ECON1_W2, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W22.final$Country_Econ <- Pew.W22.final$ECON1_W2
#
#5. Selecting options that have data 
#
Pew.W22.final[Pew.W22.final$Country_Econ %in% c(99), "Country_Econ"] <- NA
#
#6. Recoding the IV (if necessary)
Pew.W22.final$Country_Econ <- sapply(Pew.W22.final$Country_Econ,  function(x) 5 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W22.final.meta.countryecon <- Pew.W22.final[, c("BLM_supp","Country_Econ")]
#
#
#Trying another variable
#Pew.W22.final$EGHTYRSA
#table(Pew.W22.final$EGHTYRSA, useNA = "ifany") 
#Pew.W22.final$Country_Econ <- Pew.W22.final$EGHTYRSA
#Pew.W22.final[Pew.W22.final$Country_Econ %in% c(99), "Country_Econ"] <- NA
#Pew.W22.final$Country_Econ <- as.numeric(Pew.W22.final$Country_Econ)
#Pew.W22.final$Country_Econ <- car::recode(Pew.W22.final$Country_Econ, ' "3"="2"; "2"="1"; "1"="3" ')
#Pew.W22.final.meta.countryecon <- Pew.W22.final[, c("BLM_supp","Country_Econ")]
#

```





## D15. Pew Research Center: American Trends Panel Wave 68

```{r loading data - D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}


######### PATH L.M. ####################
Pew.W68 <- haven::read_spss("Roper data/Pew Research Center American Trends Panel Wave 68/W68/W68.sav")

######### PATH F.A. ####################
# Pew.W68 <- haven::read_spss("C:/Users/Flavio/Dropbox/Tamara/BLM/Roper data/Pew Research Center American Trends Panel Wave 68/W68/W68.sav")

######### PATH T.M. ####################
#Pew.W68 <- haven::read_spss("C:/Users/tmmar/Dropbox/Tamara/BLM/Roper data/Pew Research Center American Trends Panel Wave 68/W68/W68.sav")

labelled::look_for(Pew.W68) %>% dplyr::as_tibble() -> Pew.W68.codebook 


```


```{r DV, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
Pew.W68$BLM_W68
#
#2. Check the question and the labels 
sjlabelled::get_label(Pew.W68[,c("BLM_W68")])   # Values check
sjlabelled::get_labels(Pew.W68[,c("BLM_W68")])  # Values check
#
#3. Checking frequencies
table(Pew.W68$BLM_W68, useNA = "ifany")                      # Checking frequencies
prop.table(table(Pew.W68$BLM_W68, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Pew.W68$BLM_W68, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating a new dataset to manipulate variables 
Pew.W68.final <- Pew.W68
#
#5. Creating Manipulated DV (BLM_supp) 
Pew.W68.final$BLM_supp <- Pew.W68.final$BLM_W68
#
#6. Selecting options that have data (= removing missing data)
#
Pew.W68.final <- Pew.W68.final[Pew.W68.final$BLM_supp %in% c(1, 2, 3, 4),]
#
#7. Recoding the DV (if necessary)
#
Pew.W68.final$BLM_supp <- sapply(Pew.W68.final$BLM_supp,  function(x) 5 - x)


```


### IV - Income

```{r Income, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. checking the variable of interest
#
Pew.W68.final$F_INCOME

#
#2. Checking the question and the labels for the final dataset.. 
sjlabelled::get_label(Pew.W68.final[,c("F_INCOME")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("F_INCOME")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$F_INCOME, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W68.final$F_INCOME, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W68.final$F_INCOME, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$HIncome <- Pew.W68.final$F_INCOME
#
#5. Selecting options that have data 
#
Pew.W68.final[Pew.W68.final$HIncome %in% c(99), "HIncome"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Pew.W68.final.meta.income <- Pew.W68.final[, c("BLM_supp","HIncome")]
#
```


### IV - Age

```{r Age, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.W68.final$F_AGECAT
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(Pew.W68.final[,c("F_AGECAT")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("F_AGECAT")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$F_AGECAT, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W68.final$F_AGECAT, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W68.final$F_AGECAT, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$RAge <- Pew.W68.final$F_AGECAT
#
#5. Selecting options that have data 
#
Pew.W68.final[Pew.W68.final$RAge %in% c(99), "RAge"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Pew.W68.final.meta.age <- Pew.W68.final[, c("BLM_supp","RAge")]
#
```

### IV - Gender

```{r Gender, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.W68.final$F_SEX

#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(Pew.W68.final[,c("F_SEX")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("F_SEX")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$F_SEX, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W68.final$F_SEX, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W68.final$F_SEX, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$RGender <- Pew.W68.final$F_SEX
#
#5. Selecting options that have data 
#
Pew.W68.final[Pew.W68.final$RGender %in% c(99), "RGender"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Pew.W68.final.meta.gender <- Pew.W68.final[, c("BLM_supp","RGender")]
#
```

### IV - Education

```{r Education, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.W68.final$F_EDUCCAT2
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W68.final[,c("F_EDUCCAT2")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("F_EDUCCAT2")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$F_EDUCCAT2, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W68.final$F_EDUCCAT2, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W68.final$F_EDUCCAT2, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$REducation <- Pew.W68.final$F_EDUCCAT2
#
#5. Selecting options that have data 
#
Pew.W68.final[Pew.W68.final$REducation %in% c(99), "REducation"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W68.final.meta.education <- Pew.W68.final[, c("BLM_supp","REducation")]
#
```

### IV - Urbanicity

```{r Urbanicity, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.W68.final$F_METRO

#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(Pew.W68.final[,c("F_METRO")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("F_METRO")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$F_METRO, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W68.final$F_METRO, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W68.final$F_METRO, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$Urbanicity <- Pew.W68.final$F_METRO
#
# Recoding
Pew.W68.final$Urbanicity <- sapply(Pew.W68.final$Urbanicity,  function(x) 3 - x)
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Pew.W68.final.meta.urbanicity <- Pew.W68.final[, c("BLM_supp","Urbanicity")]
#
```

### IV - Marital Status

```{r Marital Status, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Married
Pew.W68.final$F_MARITAL
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W68.final[,c("F_MARITAL")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("F_MARITAL")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$F_MARITAL, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W68.final$F_MARITAL, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W68.final$F_MARITAL, useNA = "ifany")),2) # Checking %s with 2 decimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$MaritalStatus <- Pew.W68.final$F_MARITAL
#
#5. Selecting options that have data 
#
# NA
Pew.W68.final[Pew.W68.final$MaritalStatus %in% c(2,3,4,5,99), "MaritalStatus"] <- NA
#
# Never been Married
Pew.W68.final[Pew.W68.final$MaritalStatus %in% c(6), "MaritalStatus"] <- 0
#
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W68.final.meta.maritalstatus <- Pew.W68.final[, c("BLM_supp","MaritalStatus")]
#
```


### IV - Religiosity

```{r Religiosity, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.W68.final$F_RELIG

#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W68.final[,c("F_RELIG")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("F_RELIG")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$F_RELIG, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W68.final$F_RELIG, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W68.final$F_RELIG, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$Religiosity <- Pew.W68.final$F_RELIG
#
#5. Selecting options that have data 
#
Pew.W68.final[Pew.W68.final$Religiosity %in% c(99), "Religiosity"] <- NA
#
#6. Recoding the IV (if necessary)
#Pew.2016.final$Religiosity <- sapply(Pew.2016.final$Religiosity,  function(x) 15 - x)
#
Pew.W68.final[Pew.W68.final$Religiosity %in% c(1,2,3,4,5,6,7,8,11), "Religiosity"] <- 1
Pew.W68.final[Pew.W68.final$Religiosity %in% c(9,10,12), "Religiosity"] <- 0
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W68.final.meta.religiosity <- Pew.W68.final[, c("BLM_supp","Religiosity")]
#
```


### IV - Partisanship - Republicans

```{r Partisanship - Republicans, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Republican
Pew.W68.final$F_PARTY_FINAL
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W68.final[,c("F_PARTY_FINAL")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("F_PARTY_FINAL")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$F_PARTY_FINAL, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W68.final$F_PARTY_FINAL, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W68.final$F_PARTY_FINAL, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$Partisanship_Rep <- Pew.W68.final$F_PARTY_FINAL
#
#5. Selecting options that have data 
#
# NA
Pew.W68.final[Pew.W68.final$Partisanship_Rep %in% c(4,99), "Partisanship_Rep"] <- NA
#
#6. Recoding the IV (if necessary)
Pew.W68.final$Partisanship_Rep <- as.numeric(Pew.W68.final$Partisanship_Rep)
Pew.W68.final$Partisanship_Rep <- car::recode(Pew.W68.final$Partisanship_Rep, '"2"="1"; "3"="2"; "1"="3"')
#
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W68.final.meta.partisanshiprep <- Pew.W68.final[, c("BLM_supp","Partisanship_Rep")]
#
```

### IV - Ideology

```{r Ideology, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.W68.final$F_IDEO
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W68.final[,c("F_IDEO")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("F_IDEO")])  # Values check
#
#3. Checking frequencies 
#table(Pew.W68.final$F_IDEO, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W68.final$F_IDEO, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W68.final$F_IDEO, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$Ideol_Conservative <- Pew.W68.final$F_IDEO
#
#5. Selecting options that have data 
#
Pew.W68.final[Pew.W68.final$Ideol_Conservative %in% c(99), "Ideol_Conservative"] <- NA
#
#
#6. Recoding the IV (if necessary)

# 1 Liberal (or); 2 Very liberal
Pew.W68.final[Pew.W68.final$Ideol_Conservative %in% c(1,2), "Ideol_Conservative"] <- 1
#3 Moderate
Pew.W68.final[Pew.W68.final$Ideol_Conservative %in% c(3), "Ideol_Conservative"] <- 2
#4 Very conservative (or); 5 Conservative
Pew.W68.final[Pew.W68.final$Ideol_Conservative %in% c(4,5), "Ideol_Conservative"] <- 3

Pew.W68.final$Ideol_Conservative <- sapply(Pew.W68.final$Ideol_Conservative,  function(x) 4 - x)


#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W68.final.meta.ideology <- Pew.W68.final[, c("BLM_supp","Ideol_Conservative")]
#
```

### IV - Registered to Vote

```{r Registered to Vote, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.2016$REG
Pew.W68.final$F_REG
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W68.final[,c("F_REG")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("F_REG")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$F_REG, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W68.final$F_REG, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W68.final$F_REG, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$VoteReg <- Pew.W68.final$F_REG
#
#5. Selecting options that have data 
#
Pew.W68.final[Pew.W68.final$VoteReg %in% c(2, 99), "VoteReg"] <- NA

#Changing option 3 to 2, so the scale is linear
Pew.W68.final[Pew.W68.final$VoteReg %in% c(3), "VoteReg"] <- 2
#
#6. Recoding the IV (if necessary)
Pew.W68.final$VoteReg <- sapply(Pew.W68.final$VoteReg,  function(x) 3 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W68.final.meta.votereg <- Pew.W68.final[, c("BLM_supp","VoteReg")]
#
```



### IV - Illegal Immigration

```{r Illegal Immigration, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest

Pew.W68.final$LGLSTATUS_W68
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W68.final[,c("LGLSTATUS_W68")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("LGLSTATUS_W68")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$LGLSTATUS_W68, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(Pew.W68.final$LGLSTATUS_W68, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Pew.W68.final$LGLSTATUS_W68, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$Immigration_Illegal <- Pew.W68.final$LGLSTATUS_W68
#
#5. Selecting options that have data 
#
Pew.W68.final[Pew.W68.final$Immigration_Illegal %in% c(99), "Immigration_Illegal"] <- NA
#
#6. Recoding the IV (if necessary)
Pew.W68.final$Immigration_Illegal <- sapply(Pew.W68.final$Immigration_Illegal,  function(x) 3 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W68.final.meta.immigrationillegal <- Pew.W68.final[, c("BLM_supp","Immigration_Illegal")]
#
```


<br>



### IV - Race - Blacks

```{r Race - Blacks, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.W68.final$F_RACETHNMOD

#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W68.final[,c("F_RACETHNMOD")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("F_RACETHNMOD")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$F_RACETHNMOD, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W68.final$F_RACETHNMOD, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W68.final$F_RACETHNMOD, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$Race_Blacks <- Pew.W68.final$F_RACETHNMOD
#
#5. Selecting options that have data 
#
# NA
Pew.W68.final[Pew.W68.final$Race_Blacks %in% c(4, 99), "Race_Blacks"] <- NA
#
# Other races
Pew.W68.final[Pew.W68.final$Race_Blacks %in% c(1, 3, 5), "Race_Blacks"] <- 0
#
#Blacks
Pew.W68.final[Pew.W68.final$Race_Blacks %in% c(2), "Race_Blacks"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W68.final.meta.raceblacks <- Pew.W68.final[, c("BLM_supp","Race_Blacks")]
#
```

### IV - Race - Whites

```{r Race - Whites, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.W68.final$F_RACETHNMOD

#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W68.final[,c("F_RACETHNMOD")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("F_RACETHNMOD")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$F_RACETHNMOD, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W68.final$F_RACETHNMOD, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W68.final$F_RACETHNMOD, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$Race_Whites <- Pew.W68.final$F_RACETHNMOD
#
#5. Selecting options that have data 
#
# NA
Pew.W68.final[Pew.W68.final$Race_Whites %in% c(4, 99), "Race_Whites"] <- NA
#
# Other races
Pew.W68.final[Pew.W68.final$Race_Whites %in% c(2, 3, 5), "Race_Whites"] <- 0
#
#Whites
Pew.W68.final[Pew.W68.final$Race_Whites %in% c(1), "Race_Whites"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W68.final.meta.racewhites <- Pew.W68.final[, c("BLM_supp","Race_Whites")]
#
```

### IV - Race - Asians

```{r Race - Asians, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.W68.final$F_RACETHNMOD

#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W68.final[,c("F_RACETHNMOD")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("F_RACETHNMOD")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$F_RACETHNMOD, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W68.final$F_RACETHNMOD, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W68.final$F_RACETHNMOD, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$Race_Asians <- Pew.W68.final$F_RACETHNMOD

#
#5. Selecting options that have data 
#
# NA
Pew.W68.final[Pew.W68.final$Race_Asians %in% c(4, 99), "Race_Asians"] <- NA
#
# Other races
Pew.W68.final[Pew.W68.final$Race_Asians %in% c(1, 2, 3), "Race_Asians"] <- 0
#
#Asians
Pew.W68.final[Pew.W68.final$Race_Asians %in% c(5), "Race_Asians"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W68.final.meta.raceasians <- Pew.W68.final[, c("BLM_supp","Race_Asians")]
#
```

### IV - Race - Hispanic

```{r Race - Hispanic, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Pew.W68.final$F_RACETHNMOD

#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W68.final[,c("F_RACETHNMOD")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("F_RACETHNMOD")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$F_RACETHNMOD, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W68.final$F_RACETHNMOD, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W68.final$F_RACETHNMOD, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$Race_Hisp <- Pew.W68.final$F_RACETHNMOD

#
#5. Selecting options that have data 
#
# NA
Pew.W68.final[Pew.W68.final$Race_Hisp %in% c(4, 99), "Race_Hisp"] <- NA
#
# Other races
Pew.W68.final[Pew.W68.final$Race_Hisp %in% c(1, 2, 5), "Race_Hisp"] <- 0
#
#Asians
Pew.W68.final[Pew.W68.final$Race_Hisp %in% c(3), "Race_Hisp"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W68.final.meta.racehispanic <- Pew.W68.final[, c("BLM_supp","Race_Hisp")]
#
```

### IV - Attended Racial Protests

```{r Attended Racial Protests, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#Attended Highest
#Pew.W68$RACEACTIVISM_c_W68
Pew.W68.final$RACEACTIVISM_c_W68
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W68.final[,c("RACEACTIVISM_c_W68")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("RACEACTIVISM_c_W68")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$RACEACTIVISM_c_W68, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(Pew.W68.final$RACEACTIVISM_c_W68, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Pew.W68.final$RACEACTIVISM_c_W68, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$Attend_RacialProtest <- Pew.W68.final$RACEACTIVISM_c_W68
#
#5. Selecting options that have data 
#
Pew.W68.final[Pew.W68.final$Attend_RacialProtest %in% c(99), "Attend_RacialProtest"] <- NA
#
#6. Recoding the IV (if necessary)
#Pew.W68.final$Attend_RacialProtest <- sapply(Pew.W68.final$Attend_RacialProtest,  function(x) 3 - x)
#
Pew.W68.final$Attend_RacialProtest <- as.numeric(Pew.W68.final$Attend_RacialProtest)
Pew.W68.final$Attend_RacialProtest <- car::recode(Pew.W68.final$Attend_RacialProtest, ' "3"="0"; "2"="1"; ')
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W68.final.meta.attendracialprotest <- Pew.W68.final[, c("BLM_supp","Attend_RacialProtest")]
#
```


<br>




### IV - Personal experience with discrimination

```{r Personal discrimination, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.W68.final$RACESURV20_W68


#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W68.final[,c("RACESURV20_W68")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("RACESURV20_W68")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$RACESURV20_W68, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Pew.W68.final$RACESURV20_W68, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Pew.W68.final$RACESURV20_W68, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$PersDiscr <- Pew.W68.final$RACESURV20_W68


#
#5. Selecting options that have data 
#
Pew.W68.final[Pew.W68.final$PersDiscr %in% c(99), "PersDiscr"] <- NA


#6. Recoding the IV (if necessary)
#
Pew.W68.final$PersDiscr <- sapply(Pew.W68.final$PersDiscr,  function(x) 4 - x)
#
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W68.final.meta.persdiscr <- Pew.W68.final[, c("BLM_supp","PersDiscr")]
#
```

```{r Personal discrimination II, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#
Pew.W68.final$RACESURV53_a_W68
Pew.W68.final$RACESURV53_b_W68
Pew.W68.final$RACESURV53_e_W68
Pew.W68.final$RACESURV53_f_W68
Pew.W68.final$RACESURV53_h_W68
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
#sjlabelled::get_label(CNN.Kaiser.final[,c("QN20A")])   # Values check
#sjlabelled::get_labels(CNN.Kaiser.final[,c("QN20A")])  # Values check
#
#3. Checking frequencies 
#
#table(CNN.Kaiser.final$QN20A, useNA = "ifany")                      # Checking frequencies
#prop.table(table(CNN.Kaiser.final$QN20A, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(CNN.Kaiser.final$QN20A, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
#Pew.W68.final$PersDiscr.A <- Pew.W68.final$RACESURV53_a_W68
#Pew.W68.final$PersDiscr.B <- Pew.W68.final$RACESURV53_b_W68
#Pew.W68.final$PersDiscr.C <- Pew.W68.final$RACESURV53_e_W68
#Pew.W68.final$PersDiscr.D <- Pew.W68.final$RACESURV53_f_W68
#Pew.W68.final$PersDiscr.E <- Pew.W68.final$RACESURV53_h_W68
#
#5. Selecting options that have data 
#
#Pew.W68.final[Pew.W68.final$PersDiscr.A %in% c(99), "PersDiscr.A"] <- NA
#Pew.W68.final[Pew.W68.final$PersDiscr.B %in% c(99),"PersDiscr.B"] <- NA
#Pew.W68.final[Pew.W68.final$PersDiscr.C %in% c(99), "PersDiscr.C"] <- NA
#Pew.W68.final[Pew.W68.final$PersDiscr.D %in% c(99), "PersDiscr.D"] <- NA
#Pew.W68.final[Pew.W68.final$PersDiscr.E %in% c(99), "PersDiscr.E"] <- NA
#

#6. Recoding the IV (if necessary)
#
#Pew.W68.final$PersDiscr.A.rec <- Pew.W68.final$PersDiscr.A
#Pew.W68.final$PersDiscr.A.rec <- sapply(Pew.W68.final$PersDiscr.A.rec,  function(x) 3 - x)
#
#Pew.W68.final$PersDiscr.B.rec <- Pew.W68.final$PersDiscr.B
#Pew.W68.final$PersDiscr.B.rec <- sapply(Pew.W68.final$PersDiscr.B.rec,  function(x) 3 - x)
# 
#Pew.W68.final$PersDiscr.C.rec <- Pew.W68.final$PersDiscr.C
#Pew.W68.final$PersDiscr.C.rec <- sapply(Pew.W68.final$PersDiscr.C.rec,  function(x) 3 - x)
#
# 
#Pew.W68.final$PersDiscr.D.rec <- Pew.W68.final$PersDiscr.D
#Pew.W68.final$PersDiscr.D.rec <- sapply(Pew.W68.final$PersDiscr.D.rec,  function(x) 3 - x)
#
#
#Pew.W68.final$PersDiscr.E.rec <- Pew.W68.final$PersDiscr.E
#Pew.W68.final$PersDiscr.E.rec <- sapply(Pew.W68.final$PersDiscr.E.rec,  function(x) 3 - x)
#
#
# Averaging the variables
#Pew.W68.final$PersDiscr <- rowMeans(Pew.W68.final[ , c("PersDiscr.A.rec", "PersDiscr.B.rec", "PersDiscr.C.rec", "PersDiscr.D.rec", "PersDiscr.E.rec")], na.rm=TRUE)
#?rowMeans
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
#Pew.W68.final.meta.persdiscr2 <- Pew.W68.final[, c("BLM_supp","PersDiscr")]
#
```

### IV - Protests Legitimate

```{r Protest Legitimate, D15. Pew Research Center: American Trends Panel Wave 68, include=FALSE}
# 1. Instructions to check the variable of interest
#confident with personal finances - Highest

Pew.W68.final$FLOYDPROT_a_W68
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Pew.W68.final[,c("FLOYDPROT_a_W68")])   # Values check
sjlabelled::get_labels(Pew.W68.final[,c("FLOYDPROT_a_W68")])  # Values check
#
#3. Checking frequencies 
#
#table(Pew.W68.final$FLOYDPROT_a_W68, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(Pew.W68.final$FLOYDPROT_a_W68, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Pew.W68.final$FLOYDPROT_a_W68, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Pew.W68.final$Protest_Legit <- Pew.W68.final$FLOYDPROT_a_W68
#
#5. Selecting options that have data 
#
Pew.W68.final[Pew.W68.final$Protest_Legit %in% c(99), "Protest_Legit"] <- NA
#
#6. Recoding the IV (if necessary)
Pew.W68.final$Protest_Legit <- sapply(Pew.W68.final$Protest_Legit,  function(x) 5 - x)

#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Pew.W68.final.meta.protestlegit <- Pew.W68.final[, c("BLM_supp","Protest_Legit")]
#
```



## D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism
   
```{r loading data - D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}


######### PATH L.M. ####################
Washington.Kaiser <- haven::read_spss("Roper data/Washington PostKaiser Family Foundation Poll Survey on Political Rallygoing and Activism/31114982.por")

######### PATH F.A. ####################
# Washington.Kaiser <- haven::read_spss("C:/Users/Flavio/Dropbox/Tamara/BLM/Roper data/Washington PostKaiser Family Foundation Poll Survey on Political Rallygoing and Activism/31114982.por")

######### PATH T.M. ####################
#Washington.Kaiser <- haven::read_spss("C:/Users/tmmar/Dropbox/Tamara/BLM/Roper data/Washington PostKaiser Family Foundation Poll Survey on Political Rallygoing and Activism/31114982.por")

labelled::look_for(Washington.Kaiser) %>% dplyr::as_tibble() -> Washington.Kaiser.codebook 

```

### DV

* QN52. Do you consider yourself to be a supporter of the Black Lives Matter movement, or not?
   - (1) Yes, supporter of the Black Lives Matter movement
   - (2) No, not a supporter of the Black Lives Matter movement
   - (3) Haven't heard of it
   - (8) Don't Know
   - (9) Refused


```{r DV, D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}

Washington.Kaiser$QN52
#
#2. Check the question and the labels 
sjlabelled::get_label(Washington.Kaiser[,c("QN52")])   # Values check
sjlabelled::get_labels(Washington.Kaiser[,c("QN52")])  # Values check
#
#3. Checking frequencies
table(Washington.Kaiser$QN52, useNA = "ifany")                      # Checking frequencies
prop.table(table(Washington.Kaiser$QN52, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Washington.Kaiser$QN52, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating a new dataset to manipulate variables 
Washington.Kaiser.final <- Washington.Kaiser
#
#5. Creating Manipulated DV (BLM_supp) 
Washington.Kaiser.final$BLM_supp <- Washington.Kaiser.final$QN52
#
#6. Selecting options that have data (= removing missing data)
#
Washington.Kaiser.final <- Washington.Kaiser.final[Washington.Kaiser.final$BLM_supp %in% c(1, 2),]
#
#7. Recoding the DV (if necessary)
#
Washington.Kaiser.final$BLM_supp <- sapply(Washington.Kaiser.final$BLM_supp,  function(x) 3 - x)


```


### IV - Income

```{r Income, D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. checking the variable of interest
#
Washington.Kaiser.final$INCOME
#
#2. Checking the question and the labels for the final dataset.. 
sjlabelled::get_label(Washington.Kaiser.final[,c("INCOME")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("INCOME")])  # Values check
#
#3. Checking frequencies 
#
table(Washington.Kaiser.final$INCOME, useNA = "ifany")                      # Checking frequencies
prop.table(table(Washington.Kaiser.final$INCOME, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Washington.Kaiser.final$INCOME, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Washington.Kaiser.final$HIncome <- Washington.Kaiser.final$INCOME
#
#5. Selecting options that have data 
#
Washington.Kaiser.final[Washington.Kaiser.final$HIncome %in% c(8, 9), "HIncome"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Washington.Kaiser.final.meta.income <- Washington.Kaiser.final[, c("BLM_supp","HIncome")]
#
```

### IV - Age

```{r Age, D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. Instructions to check the variable of interest
#
Washington.Kaiser.final$QN49
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(Washington.Kaiser.final[,c("QN49")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("QN49")])  # Values check
#
#3. Checking frequencies 
#
table(Washington.Kaiser.final$QN49, useNA = "ifany")                      # Checking frequencies
prop.table(table(Washington.Kaiser.final$QN49, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Washington.Kaiser.final$QN49, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Washington.Kaiser.final$RAge <- Washington.Kaiser.final$QN49
#
#5. Selecting options that have data 
#
Washington.Kaiser.final[Washington.Kaiser.final$RAge %in% c(98, 99), "RAge"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Washington.Kaiser.final.meta.age <- Washington.Kaiser.final[, c("BLM_supp","RAge")]
#
```


<br> 

### IV - Gender

```{r Gender, D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. Instructions to check the variable of interest
#
Washington.Kaiser.final$RSEX
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(Washington.Kaiser.final[,c("RSEX")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("RSEX")])  # Values check
#
#3. Checking frequencies 
#
table(Washington.Kaiser.final$RSEX, useNA = "ifany")                      # Checking frequencies
prop.table(table(Washington.Kaiser.final$RSEX, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Washington.Kaiser.final$RSEX, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Washington.Kaiser.final$RGender <- Washington.Kaiser.final$RSEX
#
#5. Selecting options that have data 
#
Washington.Kaiser.final[Washington.Kaiser.final$RGender %in% c(7), "RGender"] <- NA
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Washington.Kaiser.final.meta.gender <- Washington.Kaiser.final[, c("BLM_supp","RGender")]
#
```

<br>

### IV - Education

```{r Education, D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. Instructions to check the variable of interest
#
Washington.Kaiser.final$QND12
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Washington.Kaiser.final[,c("QND12")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("QND12")])  # Values check
#
#3. Checking frequencies 
#
table(Washington.Kaiser.final$QND12, useNA = "ifany")                      # Checking frequencies
prop.table(table(Washington.Kaiser.final$QND12, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Washington.Kaiser.final$QND12, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Washington.Kaiser.final$REducation <- Washington.Kaiser.final$QND12
#
#5. Selecting options that have data 
#
Washington.Kaiser.final[Washington.Kaiser.final$REducation %in% c(6,8,9), "REducation"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Washington.Kaiser.final.meta.education <- Washington.Kaiser.final[, c("BLM_supp","REducation")]
#
```


### IV - Urbanicity

```{r Urbanicity,  D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. Instructions to check the variable of interest
#
Washington.Kaiser.final$CDC_USR
#
#2. Checking the question and the labels for the final dataset. 
sjlabelled::get_label(Washington.Kaiser.final[,c("CDC_USR")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("CDC_USR")])  # Values check
#
#3. Checking frequencies 
#
table(Washington.Kaiser.final$CDC_USR, useNA = "ifany")                      # Checking frequencies
prop.table(table(Washington.Kaiser.final$CDC_USR, useNA = "ifany"))          # Checking proportions
round(prop.table(table(Washington.Kaiser.final$CDC_USR, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Washington.Kaiser.final$Urbanicity <- Washington.Kaiser.final$CDC_USR
#
#RECODING
#Here, it returns an error saying the variable is not numeric, so we have to make it numeric.
#
Washington.Kaiser.final$Urbanicity <- as.numeric(as.factor(Washington.Kaiser.final$Urbanicity))
Washington.Kaiser.final$Urbanicity <- sapply(Washington.Kaiser.final$Urbanicity,  function(x) 4 - x)
#
#7. New data with only the variables for the correlation (in this case, income and BLM). Ending: meta.income
#
Washington.Kaiser.final.meta.urbanicity <- Washington.Kaiser.final[, c("BLM_supp","Urbanicity")]
#
```

<br>


### IV - Partisanship - Republicans

```{r Partisanship - Republicans, D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Republican
Washington.Kaiser.final$QN24
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Washington.Kaiser.final[,c("QN24")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("QN24")])  # Values check
#
#3. Checking frequencies 
#
#table(Washington.Kaiser.final$QN24, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Washington.Kaiser.final$QN24, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Washington.Kaiser.final$QN24, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Washington.Kaiser.final$Partisanship_Rep <- Washington.Kaiser.final$QN24
#
#5. Selecting options that have data 
#
# NA
Washington.Kaiser.final[Washington.Kaiser.final$Partisanship_Rep %in% c(4,8,9), "Partisanship_Rep"] <- NA
#
#6. Recoding the IV (if necessary)
Washington.Kaiser.final$Partisanship_Rep <- as.numeric(Washington.Kaiser.final$Partisanship_Rep)
Washington.Kaiser.final$Partisanship_Rep <- car::recode(Washington.Kaiser.final$Partisanship_Rep, '"2"="3"; "3"="2" ')
#
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Washington.Kaiser.final.meta.partisanshiprep <- Washington.Kaiser.final[, c("BLM_supp","Partisanship_Rep")]
#
```


<br>



### IV - Ideology

```{r Ideology, D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Washington.Kaiser$QN51
Washington.Kaiser.final$QN51
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Washington.Kaiser.final[,c("QN51")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("QN51")])  # Values check
#
#3. Checking frequencies 
#table(Washington.Kaiser.final$QN51, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Washington.Kaiser.final$QN51, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Washington.Kaiser.final$QN51, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Washington.Kaiser.final$Ideol_Conservative <- Washington.Kaiser.final$QN51
#
#5. Selecting options that have data 
#
Washington.Kaiser.final[Washington.Kaiser.final$Ideol_Conservative %in% c(4,8,9), "Ideol_Conservative"] <- NA
#
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Washington.Kaiser.final.meta.ideology <- Washington.Kaiser.final[, c("BLM_supp","Ideol_Conservative")]
#
```


<br>


### IV - Registered to Vote

```{r Registered to Vote, D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Washington.Kaiser$QN43
Washington.Kaiser.final$QN43
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Washington.Kaiser.final[,c("QN43")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("QN43")])  # Values check
#
#3. Checking frequencies 
#
#table(Washington.Kaiser.final$QN43, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Washington.Kaiser.final$QN43, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Washington.Kaiser.final$QN43, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Washington.Kaiser.final$VoteReg <- Washington.Kaiser.final$QN43
#
#5. Selecting options that have data 
#
Washington.Kaiser.final[Washington.Kaiser.final$VoteReg %in% c(8), "VoteReg"] <- NA
#
#6. Recoding the IV (if necessary)
Washington.Kaiser.final$VoteReg <- sapply(Washington.Kaiser.final$VoteReg,  function(x) 3 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Washington.Kaiser.final.meta.votereg <- Washington.Kaiser.final[, c("BLM_supp","VoteReg")]
#
```


<br>


### IV - Vote for House of Representatives

```{r Vote for House of Representatives, D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Washington.Kaiser$QN46
Washington.Kaiser.final$QN46
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Washington.Kaiser.final[,c("QN46")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("QN46")])  # Values check
#
#3. Checking frequencies 
#
#table(Washington.Kaiser.final$QN46, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Washington.Kaiser.final$QN46, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Washington.Kaiser.final$QN46, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Washington.Kaiser.final$VoteHR_Republicans <- Washington.Kaiser.final$QN46
#
#5. Selecting options that have data 
#
Washington.Kaiser.final[Washington.Kaiser.final$VoteHR_Republicans %in% c(3,4,5,8,9), "VoteHR_Republicans"] <- NA
#
#6. Recoding the IV (if necessary)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Washington.Kaiser.final.meta.votehrrep <- Washington.Kaiser.final[, c("BLM_supp","VoteHR_Republicans")]
#
```


<br>

### IV - Mexico Wall - Illegal Immigration

```{r Mexico Wall - Illegal Immigration, 17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Washington.Kaiser$QN22F
Washington.Kaiser.final$QN22F
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Washington.Kaiser.final[,c("QN22F")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("QN22F")])  # Values check
#
#3. Checking frequencies 
#
#table(Washington.Kaiser.final$QN22F, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Washington.Kaiser.final$QN22F, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Washington.Kaiser.final$QN22F, useNA = "ifany")),2) # Checking s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Washington.Kaiser.final$MexicoWall <- Washington.Kaiser.final$QN22F
#
#5. Selecting options that have data 
#
Washington.Kaiser.final[Washington.Kaiser.final$MexicoWall %in% c(8,9), "MexicoWall"] <- NA
#
#6. Recoding the IV (if necessary)
Washington.Kaiser.final$MexicoWall <- sapply(Washington.Kaiser.final$MexicoWall,  function(x) 3 - x)
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Washington.Kaiser.final.meta.mexicowall <- Washington.Kaiser.final[, c("BLM_supp","MexicoWall")]
#
```


<br>


### IV - Marital Status

```{r Marital Status, D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Higher - Married
#Washington.Kaiser$MARITAL
Washington.Kaiser.final$MARITAL
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Washington.Kaiser.final[,c("MARITAL")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("MARITAL")])  # Values check
#
#3. Checking frequencies 
#
#table(Washington.Kaiser.final$MARITAL, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Washington.Kaiser.final$MARITAL, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Washington.Kaiser.final$MARITAL, useNA = "ifany")),2) # Checking %s with 2 decimal cases

#4. Creating Manipulated variable with the same name for all datasets
#
Washington.Kaiser.final$MaritalStatus <- Washington.Kaiser.final$MARITAL
#
#5. Selecting options that have data 
#
# NA
Washington.Kaiser.final[Washington.Kaiser.final$MaritalStatus %in% c(2,3,4,5,9), "MaritalStatus"] <- NA
#
# Never been Married
Washington.Kaiser.final[Washington.Kaiser.final$MaritalStatus %in% c(6), "MaritalStatus"] <- 0
#
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Washington.Kaiser.final.meta.maritalstatus <- Washington.Kaiser.final[, c("BLM_supp","MaritalStatus")]
#
```


<br>


### IV - Trump Approval

```{r Trump Approval, D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Washington.Kaiser$QN41
Washington.Kaiser.final$QN41

#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Washington.Kaiser.final[,c("QN41")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("QN41")])  # Values check
#
#3. Checking frequencies 
#
#table(Washington.Kaiser.final$QN41, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Washington.Kaiser.final$QN41, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Washington.Kaiser.final$QN41, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Washington.Kaiser.final$Trump_App <- Washington.Kaiser.final$QN41
#
#5. Selecting options that have data 
#
Washington.Kaiser.final[Washington.Kaiser.final$Trump_App %in% c(8,9), "Trump_App"] <- NA
#
#6. Recoding the IV (if necessary)
#
#
Washington.Kaiser.final$Trump_App <- sapply(Washington.Kaiser.final$Trump_App,  function(x) 5 - x)
#     
#
                                                              
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Washington.Kaiser.final.meta.trumpapp <- Washington.Kaiser.final[, c("BLM_supp","Trump_App")]
#
#table(Washington.Kaiser.final$TRUMPAPP, useNA = "ifany")                    

#table(Washington.Kaiser.final$Trump_App, useNA = "ifany")                      

```





### IV - Race - Blacks

```{r Race - Blacks, D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Washington.Kaiser$RACETHN
Washington.Kaiser.final$RACETHN
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Washington.Kaiser.final[,c("RACETHN")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("RACETHN")])  # Values check
#
#3. Checking frequencies 
#
#table(Washington.Kaiser.final$RACETHN, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Washington.Kaiser.final$RACETHN, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Washington.Kaiser.final$RACETHN, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Washington.Kaiser.final$Race_Blacks <- Washington.Kaiser.final$RACETHN
#
#5. Selecting options that have data 
#
# NA
Washington.Kaiser.final[Washington.Kaiser.final$Race_Blacks %in% c(4,9), "Race_Blacks"] <- NA
#
# Other races
Washington.Kaiser.final[Washington.Kaiser.final$Race_Blacks %in% c(1,3), "Race_Blacks"] <- 0
#
#Blacks
Washington.Kaiser.final[Washington.Kaiser.final$Race_Blacks %in% c(2), "Race_Blacks"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Washington.Kaiser.final.meta.raceblacks <- Washington.Kaiser.final[, c("BLM_supp","Race_Blacks")]
#
```


<br>


### IV - Race - Whites

```{r Race - Whites, D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Washington.Kaiser$RACETHN
Washington.Kaiser.final$RACETHN
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Washington.Kaiser.final[,c("RACETHN")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("RACETHN")])  # Values check
#
#3. Checking frequencies 
#
#table(Washington.Kaiser.final$RACETHN, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Washington.Kaiser.final$RACETHN, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Washington.Kaiser.final$RACETHN, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Washington.Kaiser.final$Race_Whites <- Washington.Kaiser.final$RACETHN
#
#5. Selecting options that have data 
#
# NA
Washington.Kaiser.final[Washington.Kaiser.final$Race_Whites %in% c(4,9), "Race_Whites"] <- NA
#
# Other races
Washington.Kaiser.final[Washington.Kaiser.final$Race_Whites %in% c(2,3), "Race_Whites"] <- 0
#
#Whites
#Washington.Kaiser.final[Washington.Kaiser.final$Race_Whites %in% c(1), "Race_Whites"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Washington.Kaiser.final.meta.racewhites <- Washington.Kaiser.final[, c("BLM_supp","Race_Whites")]
#
```


<br>



### IV - Race - Hispanic

```{r Race - Hispanic, D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Washington.Kaiser$RACETHN
Washington.Kaiser.final$RACETHN
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Washington.Kaiser.final[,c("RACETHN")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("RACETHN")])  # Values check
#
#3. Checking frequencies 
#
#table(Washington.Kaiser.final$RACETHN, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Washington.Kaiser.final$RACETHN, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Washington.Kaiser.final$RACETHN, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Washington.Kaiser.final$Race_Hisp <- Washington.Kaiser.final$RACETHN
#
#5. Selecting options that have data 
#
# NA
Washington.Kaiser.final[Washington.Kaiser.final$Race_Hisp %in% c(4,9), "Race_Hisp"] <- NA
#
# Other races
Washington.Kaiser.final[Washington.Kaiser.final$Race_Hisp %in% c(1,2), "Race_Hisp"] <- 0
#
#Hisp
Washington.Kaiser.final[Washington.Kaiser.final$Race_Hisp %in% c(3), "Race_Hisp"] <- 1
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Washington.Kaiser.final.meta.racehispanic <- Washington.Kaiser.final[, c("BLM_supp","Race_Hisp")]
#
```


<br>





### IV - Attended Racial Protests

```{r Attended Racial Protests, D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. Instructions to check the variable of interest
#Attended Highest
#Washington.Kaiser.final$QN4A
Washington.Kaiser.final$QN4F
#Washington.Kaiser.final$QN4AF

#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Washington.Kaiser.final[,c("QN4F")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("QN4AF")])  # Values check
#
#3. Checking frequencies 
#
#table(Washington.Kaiser.final$QN4F, useNA = "ifany")                      # Checking #frequencies
#prop.table(table(Washington.Kaiser.final$QN4A, useNA = "ifany"))          # Checking #proportions
#round(prop.table(table(Washington.Kaiser.final$QN4A, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
#Washington.Kaiser.final$Attend_RacialProtest.A <- Washington.Kaiser.final$QN4F
#Washington.Kaiser.final$Attend_RacialProtest.B <- Washington.Kaiser.final$QN4AF
Washington.Kaiser.final$Attend_RacialProtest <- Washington.Kaiser.final$QN4F
#
#5. Selecting options that have data 
#
#Attend_RacialProtest.A -> Removing [1]Yes to include QN4AF / Attend_RacialProtest.B
#Washington.Kaiser.final[Washington.Kaiser.final$Attend_RacialProtest.A %in% c(1, 8, 9), "Attend_RacialProtest.A"] <- NA
#
#Attend_RacialProtest.B
#Washington.Kaiser.final[Washington.Kaiser.final$Attend_RacialProtest.B %in% c(8,9), "Attend_RacialProtest.B"] <- NA
#
Washington.Kaiser.final[Washington.Kaiser.final$Attend_RacialProtest %in% c(8), "Attend_RacialProtest"] <- NA
#6. Recoding the IV (if necessary)
#Washington.Kaiser.final$Attend_RacialProtest <- sapply(Washington.Kaiser.final$Attend_RacialProtest,  function(x) 3 - x)
#
#Washington.Kaiser.final$Attend_RacialProtest <- as.numeric(Washington.Kaiser.final$Attend_RacialProtest)
#Washington.Kaiser.final$Attend_RacialProtest <- car::recode(Washington.Kaiser.final$Attend_RacialProtest, ' "3"="0"; "2"="1"; "1"="2" ')
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#Washington.Kaiser.final$Attend_RacialProtest.A <- as.numeric(Washington.Kaiser.final$Attend_RacialProtest.A)
#Washington.Kaiser.final$Attend_RacialProtest.A <- car::recode(Washington.Kaiser.final$Attend_RacialProtest.A, ' "2"="0" ')
#Washington.Kaiser.final$Attend_RacialProtest <- rowSums(Washington.Kaiser.final[, c("Attend_RacialProtest.A","Attend_RacialProtest.B")], na.rm=T)
#

Washington.Kaiser.final$Attend_RacialProtest <- sapply(Washington.Kaiser.final$Attend_RacialProtest,  function(x) 3 - x)
#
Washington.Kaiser.final.meta.attendracialprotest <- Washington.Kaiser.final[, c("BLM_supp","Attend_RacialProtest")]
#
```


<br>




### IV - Future of the country

```{r Future of the country, D17. Washington Post/Kaiser Family Foundation Poll: Survey on Political Rallygoing and Activism, include=FALSE}
# 1. Instructions to check the variable of interest
#
#Washington.Kaiser$QN26
Washington.Kaiser.final$QN26
#
#2. Check the question and the labels for the final dataset, make sure all is correct. 
sjlabelled::get_label(Washington.Kaiser.final[,c("QN26")])   # Values check
sjlabelled::get_labels(Washington.Kaiser.final[,c("QN26")])  # Values check
#
#3. Checking frequencies 
#
#table(Washington.Kaiser.final$QN26, useNA = "ifany")                      # Checking frequencies
#prop.table(table(Washington.Kaiser.final$QN26, useNA = "ifany"))          # Checking proportions
#round(prop.table(table(Washington.Kaiser.final$QN26, useNA = "ifany")),2) # Checking %s with 2 decimal cases
#
#4. Creating Manipulated variable with the same name for all datasets
#
Washington.Kaiser.final$Country_Future <- Washington.Kaiser.final$QN26
#
#5. Selecting options that have data 
#
Washington.Kaiser.final[Washington.Kaiser.final$Country_Future %in% c(8, 9), "Country_Future"] <- NA
#
#6. Recoding the IV (if necessary)
Washington.Kaiser.final$Country_Future <- sapply(Washington.Kaiser.final$Country_Future,  function(x) 5 - x)
#
#7. Create new data with only the variables for the correlation (in this case, income and BLM). We will call this dataset meta.income
#
Washington.Kaiser.final.meta.countryfuture <- Washington.Kaiser.final[, c("BLM_supp","Country_Future")]
#
```


<br>






## Correlations and Meta-analysis

### Income

```{r meta-analysis HIncome, include=FALSE}
# 1. Running the correlation for each dataset and storing it
# A. This step is done for each IV. It can only be done after the IV (e.g., income) is coded for all datasets. 
# B. On the left, give the new dataset the name of the IV of interest. 
# C. In red, enter the name of each dataset
# D. The names of the datasets on the right have to have the same name of the dataset created in the last step (step 7) of each IV.
# E. After you run the code below, check the new generated data. It should contain the correlations between BLM and the IV of interest for each dataset. 

Income <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), correlation::correlation(Midterm.Election.W1.final.meta.income)),
      cbind(data.frame(data="Midterm.Election.W3.final"), correlation::correlation(Midterm.Election.W3.final.meta.income)),
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.income)),
      cbind(data.frame(data="CNN.Kaiser.final"), 
correlation::correlation(CNN.Kaiser.final.meta.income)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.income)),
      cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.income)),
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.income)),
      cbind(data.frame(data="NPR.Aug.final"), 
correlation::correlation(NPR.Aug.final.meta.income)),
      cbind(data.frame(data="NPR.Sep.final"), 
correlation::correlation(NPR.Sep.final.meta.income)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.income)),
      cbind(data.frame(data="Pew.W22.final"), 
correlation::correlation(Pew.W22.final.meta.income)),
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.income)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.income)))
#cbind(data.frame(data="Kaiser.2020.final"), 
#correlation::correlation(Kaiser.2020.final.meta.income)),
#cbind(data.frame(data="NPR.Aug.final"), 
#correlation::correlation(NPR.Aug.final.meta.income)))
#

#
# 2. Running the meta-analysis
# https://bookdown.org/MathiasHarrer/Doing_Meta_Analysis_in_R/correlations.html
# A. On the left, change the name of the IV
# B. Replace the 2 lines of code (indicated below) with the name of the dataset created in the last step
Income.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Income,         # replace data name
                              studlab = Income$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```

### Age

```{r meta-analysis Age, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Age <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), correlation::correlation(Midterm.Election.W1.final.meta.age)),
      cbind(data.frame(data="Midterm.Election.W3.final"), correlation::correlation(Midterm.Election.W3.final.meta.age)),
      cbind(data.frame(data="CNN.Kaiser.final"), 
correlation::correlation(CNN.Kaiser.final.meta.age)),
      cbind(data.frame(data="CBS.2016.final"), 
correlation::correlation(CBS.2016.final.meta.age)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.age)),
      cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.age)),
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.age)),
      cbind(data.frame(data="NPR.Aug.final"), 
correlation::correlation(NPR.Aug.final.meta.age)),
      cbind(data.frame(data="NPR.Sep.final"), 
correlation::correlation(NPR.Sep.final.meta.age)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.age)),
      cbind(data.frame(data="Pew.W22.final"), 
correlation::correlation(Pew.W22.final.meta.age)),
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.age)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.age)))
#
# 2. Running the meta-analysis
Age.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Age,         # replace data name
                              studlab = Age$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```

### Gender

```{r meta-analysis RGender, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Gender <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), correlation::correlation(Midterm.Election.W1.final.meta.gender)),
      cbind(data.frame(data="Midterm.Election.W3.final"), correlation::correlation(Midterm.Election.W3.final.meta.gender)),
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.gender)),
      cbind(data.frame(data="CNN.Kaiser.final"), 
correlation::correlation(CNN.Kaiser.final.meta.gender)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.gender)),
      cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.gender)),
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.gender)),
      cbind(data.frame(data="NPR.Aug.final"), 
correlation::correlation(NPR.Aug.final.meta.gender)),
      cbind(data.frame(data="NPR.Sep.final"), 
correlation::correlation(NPR.Sep.final.meta.gender)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.gender)),
      cbind(data.frame(data="Pew.W22.final"), 
correlation::correlation(Pew.W22.final.meta.gender)),
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.gender)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.gender)))

# 2. Running the meta-analysis
Gender.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Gender,         # replace data name
                              studlab = Gender$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```


### Education

```{r meta-analysis Reducation, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Education <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), correlation::correlation(Midterm.Election.W1.final.meta.education)),
      cbind(data.frame(data="Midterm.Election.W3.final"), correlation::correlation(Midterm.Election.W3.final.meta.education)),
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.education)),
      cbind(data.frame(data="CNN.Kaiser.final"), 
correlation::correlation(CNN.Kaiser.final.meta.education)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.education)),
      cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.education)),
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.education)),
      cbind(data.frame(data="NPR.Aug.final"), 
correlation::correlation(NPR.Aug.final.meta.education)),
      cbind(data.frame(data="NPR.Sep.final"), 
correlation::correlation(NPR.Sep.final.meta.education)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.education)),
      cbind(data.frame(data="Pew.W22.final"), 
correlation::correlation(Pew.W22.final.meta.education)),
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.education)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.education)))
# 2. Running the meta-analysis
Education.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Education,         # replace data name
                              studlab = Education$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```


### Urbanicity

```{r meta-analysis Urbanicity, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Urbanicity <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), correlation::correlation(Midterm.Election.W1.final.meta.urbanicity)),
      cbind(data.frame(data="Midterm.Election.W3.final"), correlation::correlation(Midterm.Election.W3.final.meta.urbanicity)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.urbanicity)),
      cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.urbanicity)),
      cbind(data.frame(data="NPR.Aug.final"), 
correlation::correlation(NPR.Aug.final.meta.urbanicity)),
      cbind(data.frame(data="NPR.Sep.final"), 
correlation::correlation(NPR.Sep.final.meta.urbanicity)),
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.urbanicity)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.urbanicity)))
#
# 2. Running the meta-analysis

Urbanicity.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Urbanicity,         # replace data name
                              studlab = Urbanicity$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```


### Partisanship - Republicans

```{r meta-analysis Partisanship - Republicans, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Partisanship_Rep <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), correlation::correlation(Midterm.Election.W1.final.meta.partisanshiprep)),
      cbind(data.frame(data="Midterm.Election.W3.final"), correlation::correlation(Midterm.Election.W3.final.meta.partisanshiprep)),
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.partisanshiprep)),
      cbind(data.frame(data="CNN.Kaiser.final"), 
correlation::correlation(CNN.Kaiser.final.meta.partisanshiprep)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.partisanshiprep)),
      cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.partisanshiprep)),
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.partisanshiprep)),
      cbind(data.frame(data="NPR.Aug.final"), 
correlation::correlation(NPR.Aug.final.meta.partisanshiprep)),
      cbind(data.frame(data="NPR.Sep.final"), 
correlation::correlation(NPR.Sep.final.meta.partisanshiprep)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.partisanshiprep)),
      cbind(data.frame(data="Pew.W22.final"), 
correlation::correlation(Pew.W22.final.meta.partisanshiprep)),
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.partisanshiprep)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.partisanshiprep)))

# 2. Running the meta-analysis
Partisanship_Rep.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Partisanship_Rep,         # replace data name
                              studlab = Partisanship_Rep$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```



### Ideology

```{r meta-analysis Ideology, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Ideology <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), correlation::correlation(Midterm.Election.W1.final.meta.ideology)),
      cbind(data.frame(data="Midterm.Election.W3.final"), correlation::correlation(Midterm.Election.W3.final.meta.ideology)),
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.ideology)),
      cbind(data.frame(data="CNN.Kaiser.final"), 
correlation::correlation(CNN.Kaiser.final.meta.ideology)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.ideology)),
      cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.ideology)),
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.ideology)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.ideology)),
      cbind(data.frame(data="Pew.W22.final"), 
correlation::correlation(Pew.W22.final.meta.ideology)),
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.ideology)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.ideology)))
# 2. Running the meta-analysis
Ideology.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Ideology,         # replace data name
                              studlab = Ideology$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```



### Religiosity

```{r meta-analysis Religiosity, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Religiosity <- 
rbind(
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.religiosity)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.religiosity)),
      cbind(data.frame(data="Pew.W22.final"), 
correlation::correlation(Pew.W22.final.meta.religiosity)),
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.religiosity)))

# 2. Running the meta-analysis
Religiosity.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Religiosity,         # replace data name
                              studlab = Religiosity$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```



### Police Misconduct

```{r meta-analysis Police Misconduct, include=FALSE}
# 1. Running the correlation for each dataset and storing it
PoliceMisconduct <- 
rbind(
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.policemisconduct)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.policemisconduct)),
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.policemisconduct)))


# 2. Running the meta-analysis
PoliceMisconduct.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = PoliceMisconduct,         # replace data name
                              studlab = PoliceMisconduct$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```



### Registered to vote

```{r meta-analysis Registered to vote, include=FALSE}
# 1. Running the correlation for each dataset and storing it
VoteReg <- 
rbind(
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.votereg)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.votereg)),
      cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.votereg)),
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.votereg)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.votereg)),
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.votereg)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.votereg)))

# 2. Running the meta-analysis
VoteReg.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = VoteReg,         # replace data name
                              studlab = VoteReg$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```



### Vote Intention

```{r meta-analysis Vote Intention, include=FALSE}
# 1. Running the correlation for each dataset and storing it
VoteInt <- 
rbind(
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.voteint)),
      cbind(data.frame(data="NPR.Aug.final"), 
correlation::correlation(NPR.Aug.final.meta.voteint)),
      cbind(data.frame(data="NPR.Sep.final"), 
correlation::correlation(NPR.Sep.final.meta.voteint)),
      cbind(data.frame(data="Pew.W22.final"), 
correlation::correlation(Pew.W22.final.meta.voteint)))

# 2. Running the meta-analysis
VoteInt.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = VoteInt,         # replace data name
                              studlab = VoteInt$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```



### Vote for House of Representatives

```{r meta-analysis Vote for House of Representatives, include=FALSE}
# 1. Running the correlation for each dataset and storing it
# Votes for Republicans coded as higher values
VoteHR_Republicans <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), correlation::correlation(Midterm.Election.W1.final.meta.votehrrep)),
      cbind(data.frame(data="Midterm.Election.W3.final"), correlation::correlation(Midterm.Election.W3.final.meta.votehrrep)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.votehrrep)))

# 2. Running the meta-analysis
VoteHR_Republicans.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = VoteHR_Republicans,         # replace data name
                              studlab = VoteHR_Republicans$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```


### Obama Approval

```{r meta-analysis Obama Approval, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Obama_App <- 
rbind(
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.obamaapp)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.obamaapp)),
      cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.obamaapp)))

# 2. Running the meta-analysis
Obama_App.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Obama_App,         # replace data name
                              studlab = Obama_App$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```



### Trump Approval

```{r meta-analysis Trump Approval, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Trump_App <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), correlation::correlation(Midterm.Election.W1.final.meta.trumpapp)),
      cbind(data.frame(data="Midterm.Election.W3.final"), correlation::correlation(Midterm.Election.W3.final.meta.trumpapp)),
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.trumpapp)),
      cbind(data.frame(data="NPR.Aug.final"), 
correlation::correlation(NPR.Aug.final.meta.trumpapp)),
      cbind(data.frame(data="NPR.Sep.final"), 
correlation::correlation(NPR.Sep.final.meta.trumpapp)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.trumpapp)))

# 2. Running the meta-analysis
TrumpApp.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Trump_App,         # replace data name
                              studlab = Trump_App$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```



### Clinton - Favorability

```{r meta-analysis Clinton - Favorability, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Hillary_Fav <- 
rbind(
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.hillaryfav)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.hillaryfav)),
      cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.hillaryfav)))

# 2. Running the meta-analysis
Hillary_Fav.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Hillary_Fav,         # replace data name
                              studlab = Hillary_Fav$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```




### Trump - Favorability

```{r meta-analysis Trump - Favorability, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Trump_Fav <- 
rbind(
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.trumpfav)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.trumpfav)),
      cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.trumpfav)))

# 2. Running the meta-analysis
Trump_Fav.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Trump_Fav,         # replace data name
                              studlab = Trump_Fav$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```





### Vote 2016 - Clinton VS Trump

```{r meta-analysis Vote 2016 - Hillary Clinton, include=FALSE}
# 1. Running the correlation for each dataset and storing it
#Vote for Clinton coded as higher
Vote16_ClintonVSTrump <- 
rbind(
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.vote16clintonvstrump)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.vote16clintonvstrump)),
#      cbind(data.frame(data="NPR.Aug.final"), 
#correlation::correlation(NPR.Aug.final.meta.vote16hillary)),
      cbind(data.frame(data="Pew.W22.final"), 
correlation::correlation(Pew.W22.final.meta.vote16clintonvstrump)))

# 2. Running the meta-analysis
Vote16_ClintonVSTrump.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Vote16_ClintonVSTrump,         # replace data name
                              studlab = Vote16_ClintonVSTrump$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```




### Who would better handle Race Relations: Trump or Biden?

```{r meta-analysis Who would better handle Race Relations: Trump or Biden?, include=FALSE}
# 1. Running the correlation for each dataset and storing it
# Biden coded as higher values
BidenvsTrump_Race  <- 
rbind(
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.bidentrump_race)),
      cbind(data.frame(data="NPR.Aug.final"), 
correlation::correlation(NPR.Aug.final.meta.bidentrump_race)),
      cbind(data.frame(data="NPR.Sep.final"), 
correlation::correlation(NPR.Sep.final.meta.bidentrump_race)))

# 2. Running the meta-analysis
BidenvsTrump_Race.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = BidenvsTrump_Race ,         # replace data name
                              studlab = BidenvsTrump_Race $data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```



### Mexico Wall - Illegal Immigration

```{r meta-analysis Mexico Wall - Illegal Immigration, include=FALSE}
# 1. Running the correlation for each dataset and storing it
MexicoWall <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), correlation::correlation(Midterm.Election.W1.final.meta.mexicowall)),
      cbind(data.frame(data="Midterm.Election.W3.final"), correlation::correlation(Midterm.Election.W3.final.meta.mexicowall)),
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.mexicowall)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.mexicowall)))

# 2. Running the meta-analysis
MexicoWall.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = MexicoWall,         # replace data name
                              studlab = MexicoWall$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```



### Immigration - Jobs

```{r meta-analysis Immigration - Jobs, include=FALSE}
# 1. Running the correlation for each dataset and storing it
#Higher numbers mean agreement with the statement that immigrants take jobs from Americans
Immigration_Jobs <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), correlation::correlation(Midterm.Election.W1.final.meta.immigrationjobs)),
      cbind(data.frame(data="Midterm.Election.W3.final"), correlation::correlation(Midterm.Election.W3.final.meta.immigrationjobs)),
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.immigrationjobs)))

# 2. Running the meta-analysis
Immigration_Jobs.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Immigration_Jobs,         # replace data name
                              studlab = Immigration_Jobs$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```



### Illegal Immigration

```{r meta-analysis Illegal Immigration, include=FALSE}
# 1. Running the correlation for each dataset and storing it
#Higher numbers mean agreement with the statement that immigrants take jobs from Americans
Immigration_Illegal <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), 
correlation::correlation(Midterm.Election.W1.final.meta.immigrationillegal)),
      cbind(data.frame(data="Midterm.Election.W3.final"), 
correlation::correlation(Midterm.Election.W3.final.meta.immigrationillegal)),
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.immigrationillegal)),
      cbind(data.frame(data="Pew.W68.final"),
correlation::correlation(Pew.W68.final.meta.immigrationillegal)))

# 2. Running the meta-analysis
Immigration_Illegal.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Immigration_Illegal,         # replace data name
                              studlab = Immigration_Illegal$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```




### Race Relations - Better

```{r meta-analysis Race Relations - Better, include=FALSE}
# 1. Running the correlation for each dataset and storing it
# Race relations becoming better coded as higher numbers
RaceRelations_Better <- 
rbind(
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.racerelationsbetter)),
      cbind(data.frame(data="CNN.Kaiser.final"), 
correlation::correlation(CNN.Kaiser.final.meta.racerelationsbetter)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.racerelationsbetter)),
      cbind(data.frame(data="Pew.W22.final"), 
correlation::correlation(Pew.W22.final.meta.racerelationsbetter)))

# 2. Running the meta-analysis
RaceRelationsBetter.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = RaceRelations_Better,         # replace data name
                              studlab = RaceRelations_Better$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```



### Systematic Racism

```{r meta-analysis Systematic Racism, include=FALSE}
# 1. Running the correlation for each dataset and storing it
#Higher numbers mean agreement with the statement that immigrants take jobs from Americans
SystematicRacism <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), 
correlation::correlation(Midterm.Election.W1.final.meta.systematicracism)),
      cbind(data.frame(data="Midterm.Election.W3.final"), 
correlation::correlation(Midterm.Election.W3.final.meta.systematicracism)),
      cbind(data.frame(data="CNN.Kaiser.final"),
correlation::correlation(CNN.Kaiser.final.meta.systematicracism)),
      cbind(data.frame(data="Pew.2016.final"),
correlation::correlation(Pew.2016.final.meta.systematicracism)))

# 2. Running the meta-analysis
SystematicRacism.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = SystematicRacism,         # replace data name
                              studlab = SystematicRacism$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```




### Perceptions on racial discrimination (against Blacks)

```{r meta-analysis Perceptions on racial discrimination (against Blacks), include=FALSE}
# 1. Running the correlation for each dataset and storing it
RacialDisc <- 
rbind(
      cbind(data.frame(data="CNN.Kaiser.final"), 
correlation::correlation(CNN.Kaiser.final.meta.racialdisc)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.racialdisc)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.racialdisc)))

# 2. Running the meta-analysis
RacialDisc.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = RacialDisc,         # replace data name
                              studlab = RacialDisc$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```



### Personal experience with discrimination

```{r meta-analysis Personal experience with discrimination, include=FALSE}
# 1. Running the correlation for each dataset and storing it
PersDiscr <- 
rbind(
      cbind(data.frame(data="CNN.Kaiser.final"), 
correlation::correlation(CNN.Kaiser.final.meta.persdiscr)),
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.persdiscr)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.persdiscr)),
      #cbind(data.frame(data="Pew.W68.final"), 
#correlation::correlation(Pew.W68.final.meta.persdiscr))
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.persdiscr)))

# 2. Running the meta-analysis
PersDiscr.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = PersDiscr,         # replace data name
                              studlab = PersDiscr$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```

### Marital Status

```{r meta-analysis Marital Status, include=FALSE}
# 1. Running the correlation for each dataset and storing it
#Married vs Single (Married was coded with higher values)
Married <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), correlation::correlation(Midterm.Election.W1.final.meta.maritalstatus)),
      cbind(data.frame(data="Midterm.Election.W3.final"), correlation::correlation(Midterm.Election.W3.final.meta.maritalstatus)),
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.maritalstatus)),
      cbind(data.frame(data="CNN.Kaiser.final"), 
correlation::correlation(CNN.Kaiser.final.meta.maritalstatus)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.maritalstatus)),
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.maritalstatus)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.maritalstatus)),
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.maritalstatus)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.maritalstatus)))

# 2. Running the meta-analysis
Married.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Married,         # replace data name
                              studlab = Married$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```

### Employment Status

```{r meta-analysis Employment Status, include=FALSE}
# 1. Running the correlation for each dataset and storing it
# Employed vs Retired (Employed coded as higher values)
Employed <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), correlation::correlation(Midterm.Election.W1.final.meta.employmentstatus)),
      cbind(data.frame(data="Midterm.Election.W3.final"), correlation::correlation(Midterm.Election.W3.final.meta.employmentstatus)),
      cbind(data.frame(data="CNN.Kaiser.final"), 
correlation::correlation(CNN.Kaiser.final.meta.employmentstatus)),
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.employmentstatus)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.employmentstatus)))

# 2. Running the meta-analysis
Employed.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Employed,         # replace data name
                              studlab = Employed$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```

### Prospective Vote 2020 - Trump VS Biden

```{r meta-analysis rospective Vote 2020, include=FALSE}
# 1. Running the correlation for each dataset and storing it
#Coding voting from Trump as the higher number

Vote2020_TrumpvsBiden <- 
rbind(
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.pvote20)),
      cbind(data.frame(data="NPR.Aug.final"), 
correlation::correlation(NPR.Aug.final.meta.pvote20)),
      cbind(data.frame(data="NPR.Sep.final"), 
correlation::correlation(NPR.Sep.final.meta.pvote20)))

# 2. Running the meta-analysis
Vote2020_TrumpvsBiden.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Vote2020_TrumpvsBiden,         # replace data name
                              studlab = Vote2020_TrumpvsBiden$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```

### Race - Blacks

```{r meta-analysis Race - Blacks, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Race_Blacks <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), correlation::correlation(Midterm.Election.W1.final.meta.raceblacks)),
      cbind(data.frame(data="Midterm.Election.W3.final"), correlation::correlation(Midterm.Election.W3.final.meta.raceblacks)),
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.raceblacks)),
      cbind(data.frame(data="CNN.Kaiser.final"), 
correlation::correlation(CNN.Kaiser.final.meta.raceblacks)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.raceblacks)),
      cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.raceblacks)),
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.raceblacks)),
      cbind(data.frame(data="NPR.Aug.final"), 
correlation::correlation(NPR.Aug.final.meta.raceblacks)),
      cbind(data.frame(data="NPR.Sep.final"), 
correlation::correlation(NPR.Sep.final.meta.raceblacks)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.raceblacks)),
      cbind(data.frame(data="Pew.W22.final"), 
correlation::correlation(Pew.W22.final.meta.raceblacks)),
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.raceblacks)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.raceblacks)))



# 2. Running the meta-analysis
Race_Blacks.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Race_Blacks,         # replace data name
                              studlab = Race_Blacks$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```

### Race - Whites

```{r meta-analysis Race - Whites, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Race_Whites <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), correlation::correlation(Midterm.Election.W1.final.meta.racewhites)),
      cbind(data.frame(data="Midterm.Election.W3.final"), correlation::correlation(Midterm.Election.W3.final.meta.racewhites)),
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.racewhites)),
      cbind(data.frame(data="CNN.Kaiser.final"), 
correlation::correlation(CNN.Kaiser.final.meta.racewhites)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.racewhites)),
      cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.racewhites)),
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.racewhites)),
      cbind(data.frame(data="NPR.Aug.final"), 
correlation::correlation(NPR.Aug.final.meta.racewhites)),
      cbind(data.frame(data="NPR.Sep.final"), 
correlation::correlation(NPR.Sep.final.meta.racewhites)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.racewhites)),
      cbind(data.frame(data="Pew.W22.final"), 
correlation::correlation(Pew.W22.final.meta.racewhites)),
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.racewhites)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.racewhites)))


# 2. Running the meta-analysis
Race_Whites.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Race_Whites,         # replace data name
                              studlab = Race_Whites$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```

### Race - Hispanic

```{r meta-analysis Race - Hispanic, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Race_Hispanic <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), 
correlation::correlation(Midterm.Election.W1.final.meta.racehispanic)),
      cbind(data.frame(data="Midterm.Election.W3.final"), 
correlation::correlation(Midterm.Election.W3.final.meta.racehispanic)),
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.racehispanic)),
      cbind(data.frame(data="CNN.Kaiser.final"), 
correlation::correlation(CNN.Kaiser.final.meta.racehispanic)),
     cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.racehispanic)),
     cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.racehispanic)),
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.racehispanic)),
      cbind(data.frame(data="NPR.Aug.final"), 
correlation::correlation(NPR.Aug.final.meta.racehispanic)),
      cbind(data.frame(data="NPR.Sep.final"), 
correlation::correlation(NPR.Sep.final.meta.racehispanic)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.racehispanic)),
      cbind(data.frame(data="Pew.W22.final"), 
correlation::correlation(Pew.W22.final.meta.racehispanic)),
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.racehispanic)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.racehispanic)))

# 2. Running the meta-analysis
Race_Hispanic.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Race_Hispanic,         # replace data name
                              studlab = Race_Hispanic$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```

### Race - Asians

```{r meta-analysis Race - Asians, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Race_Asians <- 
rbind(
      cbind(data.frame(data="Midterm.Election.W1.final"), correlation::correlation(Midterm.Election.W1.final.meta.raceasians)),
      cbind(data.frame(data="Midterm.Election.W3.final"), correlation::correlation(Midterm.Election.W3.final.meta.raceasians)),
      cbind(data.frame(data="CNN.Kaiser.final"), 
correlation::correlation(CNN.Kaiser.final.meta.raceasians)),
      cbind(data.frame(data="CNN.NORC.final"), 
correlation::correlation(CNN.NORC.final.meta.raceasians)),
      cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.raceasians)),
      cbind(data.frame(data="NPR.Aug.final"), 
correlation::correlation(NPR.Aug.final.meta.raceasians)),
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.raceasians)),
      cbind(data.frame(data="NPR.Sep.final"), 
correlation::correlation(NPR.Sep.final.meta.raceasians)))

# 2. Running the meta-analysis
Race_Asians.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Race_Asians,         # replace data name
                              studlab = Race_Asians$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```


### Attended Racial Protest

```{r meta-analysis Attended Racial Protest, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Attend_RacialProtest <- 
rbind(
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.attendracialprotest)),
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.attendracialprotest)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.attendracialprotest)))
# 2. Running the meta-analysis
AttendRacialProtest.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Attend_RacialProtest,         # replace data name
                              studlab = Attend_RacialProtest$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```




### Personal Finances

```{r meta-analysis Personal Finances, include=FALSE}
# 1. Running the correlation for each dataset and storing it
# Satisfaction with personal finances coded as higher numbers
Pers_Finances <- 
rbind(
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.persfinances)),
      cbind(data.frame(data="CNN.Kaiser.final"), 
correlation::correlation(CNN.Kaiser.final.meta.persfinances)),
      cbind(data.frame(data="Pew.2016.final"), 
correlation::correlation(Pew.2016.final.meta.persfinances)),
      cbind(data.frame(data="Pew.W22.final"), 
correlation::correlation(Pew.W22.final.meta.persfinances)))

# 2. Running the meta-analysis
PersFinances.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Pers_Finances,         # replace data name
                              studlab = Pers_Finances$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```




### Future of the country

```{r meta-analysis Future of the country, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Country_Future <- 
rbind(
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.countryfuture)),
      cbind(data.frame(data="Kaiser.2020.final"), 
correlation::correlation(Kaiser.2020.final.meta.countryfuture)),
      cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.countryfuture)),
      cbind(data.frame(data="Washington.Kaiser.final"), 
correlation::correlation(Washington.Kaiser.final.meta.countryfuture)))

# 2. Running the meta-analysis
CountryFuture.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Country_Future,         # replace data name
                              studlab = Country_Future$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```

### Country Economy

```{r meta-analysis Country Economy, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Country_Economy <- 
rbind(
      cbind(data.frame(data="CBS.2016.final"),
correlation::correlation(CBS.2016.final.meta.countryecon)),
      cbind(data.frame(data="CNN.NORC.Elections.final"), 
correlation::correlation(CNN.NORC.Elections.final.meta.countryecon)),
      cbind(data.frame(data="Pew.W22.final"), 
correlation::correlation(Pew.W22.final.meta.countryecon)))


# 2. Running the meta-analysis
Country_Economy.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Country_Economy,         # replace data name
                              studlab = Country_Economy$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```


### Protests Legitimacy

```{r meta-analysis Protests Legitimacy, include=FALSE}
# 1. Running the correlation for each dataset and storing it
Protest_Legitimacy <- 
rbind(
      cbind(data.frame(data="CNN.Kaiser.final"),
correlation::correlation(CNN.Kaiser.final.meta.protestlegit)),
      cbind(data.frame(data="NPR.Sep.final"), 
correlation::correlation(NPR.Sep.final.meta.protestlegit)),
      cbind(data.frame(data="NPR.Aug.final"), 
correlation::correlation(NPR.Aug.final.meta.protestlegit)),
      cbind(data.frame(data="Pew.W68.final"), 
correlation::correlation(Pew.W68.final.meta.protestlegit)))


# 2. Running the meta-analysis
Protest_Legitimacy.m.cor <- meta::metacor(r, 
                              n_Obs, 
                              data = Protest_Legitimacy,         # replace data name
                              studlab = Protest_Legitimacy$data, # replace data name
                              sm = "COR",
                              method.tau = "SJ")
```





# Results

```{r, include=FALSE}
data.objects <- dput(ls())
#
data.objects[str_detect(data.objects, ".m.cor")]
```

## Demographics

### Race (Blacks vs other races)

```{r}
Race_Blacks.m.cor
```

### Race (Whites vs other races)

```{r}
Race_Whites.m.cor
```

### Race (Hispanic vs other races)

```{r}
Race_Hispanic.m.cor
```

### Race (Asians vs other races)

```{r}
Race_Asians.m.cor
```


### Age

```{r}
Age.m.cor
```

### Income

```{r}
Income.m.cor
```

### Gender 

Higher values coded as female

```{r}
Gender.m.cor
```

### Education

```{r}
Education.m.cor
```

### Urbanicity 

```{r}
Urbanicity.m.cor
```

### Religiosity

```{r}
Religiosity.m.cor
```

### Marital status (Married vs Single)

Higher values for married

```{r}
Married.m.cor
```

### Employment status (Employed vs Retired)

Higher values for employed

```{r}
Employed.m.cor
```

### Partisanship 

Higher values for Republicans

```{r}
Partisanship_Rep.m.cor
```

### Ideology

Higher values for Conservatism

```{r}
Ideology.m.cor
```

## Voting behavior

### Registered to vote

```{r}
VoteReg.m.cor
```

### Intention to vote 

```{r}
VoteInt.m.cor
```

### Vote for House of Representatives

Higher values for voting for Republicans (as opposed to Democrats)

```{r}
VoteHR_Republicans.m.cor
```

## Support for Politicians

### Approval of Trump's Presidency

```{r}
TrumpApp.m.cor
```


### Favorability towards Trump

```{r}
Trump_Fav.m.cor
```

### Prospective Vote 2020 (Trump vs Biden)

Higher values for prospective vote for Trump

```{r}
Vote2020_TrumpvsBiden.m.cor
```

### Voting in 2016 elections (Trump vs Hillary)

Higher values for voting for Hillary Clinton

```{r}
Vote16_ClintonVSTrump.m.cor
```

### Favorability towards Hillary Clinton

```{r}
Hillary_Fav.m.cor
```

### Who would better handle race relations: Biden or Trump?

Higher values for favoring Biden

```{r}
BidenvsTrump_Race.m.cor
```

### Approval of Obama's presidency

```{r}
Obama_App.m.cor
```

## Attitudes towards Immigration

### Support building wall to stop illegal immigration

```{r}
MexicoWall.m.cor
```

### Immigrants will take jobs away

```{r}
Immigration_Jobs.m.cor
```

### Illegal Immigration

```{r}
Immigration_Illegal.m.cor
```


## Views on issues involving Police Officers

### Police Misconduct (based on Race and Ethnicity)

```{r}
PoliceMisconduct.m.cor
```

## Views on racial discrimination

### Personal experiences with discrimination

```{r}
PersDiscr.m.cor
```

### Perceptions on racial discrimination (against Blacks)

```{r}
RacialDisc.m.cor
```

### Race relations are getting better 

```{r}
RaceRelationsBetter.m.cor
```

### Attended Racial Protest

```{r}
AttendRacialProtest.m.cor
```

### Systematic Racism

```{r}
SystematicRacism.m.cor
```

## Saving data

```{r}
save.image(file = "full_data.RData")
```

# Multiple Meta-Analyses

```{r}
dt.Viz <- data.frame(rbind(
  ##########################
  # HEADING: Demographics  #
  ########################
  cbind(
  Var        = "Demographics",
  N          = NA, 
  k          = NA,
  tau2       = NA,
  I2         = NA,
  sig.het    = NA,
  r.fix      = NA,
  r.fix.pval = NA,
  r.fix.low  = NA,
  r.fix.up   = NA,
  r          = NA,
  r.pval     = NA,
  r.low      = NA,
  r.up       = NA),
  #
  # Age.m.cor
  #-----------
  cbind(
  Var        = "Age",
  N          = sum(Age.m.cor$n), 
  k          = Age.m.cor$k,
  tau2       = Age.m.cor$tau2,
  I2         = Age.m.cor$I2,
  sig.het    = Age.m.cor$pval.Q,
  r.fix      = Age.m.cor$TE.fixed,
  r.fix.pval = Age.m.cor$pval.fixed,
  r.fix.low  = Age.m.cor$lower.fixed,
  r.fix.up   = Age.m.cor$upper.fixed,
  r          = Age.m.cor$TE.random,
  r.pval     = Age.m.cor$pval.random,
  r.low      = Age.m.cor$lower.random,
  r.up       = Age.m.cor$upper.random),
  #
  # Education.m.cor
  #-----------
  cbind(
  Var        = "Education",
  N          = sum(Education.m.cor$n), 
  k          = Education.m.cor$k,
  tau2       = Education.m.cor$tau2,
  I2         = Education.m.cor$I2,
  sig.het    = Education.m.cor$pval.Q,
  r.fix      = Education.m.cor$TE.fixed,
  r.fix.pval = Education.m.cor$pval.fixed,
  r.fix.low  = Education.m.cor$lower.fixed,
  r.fix.up   = Education.m.cor$upper.fixed,
  r          = Education.m.cor$TE.random,
  r.pval     = Education.m.cor$pval.random,
  r.low      = Education.m.cor$lower.random,
  r.up       = Education.m.cor$upper.random),
  #
  # Gender.m.cor
  #-----------
  cbind(
  Var        = "Female (vs Male)",
  N          = sum(Gender.m.cor$n), 
  k          = Gender.m.cor$k,
  tau2       = Gender.m.cor$tau2,
  I2         = Gender.m.cor$I2,
  sig.het    = Gender.m.cor$pval.Q,
  r.fix      = Gender.m.cor$TE.fixed,
  r.fix.pval = Gender.m.cor$pval.fixed,
  r.fix.low  = Gender.m.cor$lower.fixed,
  r.fix.up   = Gender.m.cor$upper.fixed,
  r          = Gender.m.cor$TE.random,
  r.pval     = Gender.m.cor$pval.random,
  r.low      = Gender.m.cor$lower.random,
  r.up       = Gender.m.cor$upper.random),
  #
  # Income.m.cor
  #-----------
  cbind(
  Var        = "Income",
  N          = sum(Income.m.cor$n), 
  k          = Income.m.cor$k,
  tau2       = Income.m.cor$tau2,
  I2         = Income.m.cor$I2,
  sig.het    = Income.m.cor$pval.Q,
  r.fix      = Income.m.cor$TE.fixed,
  r.fix.pval = Income.m.cor$pval.fixed,
  r.fix.low  = Income.m.cor$lower.fixed,
  r.fix.up   = Income.m.cor$upper.fixed,
  r          = Income.m.cor$TE.random,
  r.pval     = Income.m.cor$pval.random,
  r.low      = Income.m.cor$lower.random,
  r.up       = Income.m.cor$upper.random),
  #
  # Urbanicity.m.cor
  #-----------
  cbind(
  Var        = "Urbanicity",
  N          = sum(Urbanicity.m.cor$n), 
  k          = Urbanicity.m.cor$k,
  tau2       = Urbanicity.m.cor$tau2,
  I2         = Urbanicity.m.cor$I2,
  sig.het    = Urbanicity.m.cor$pval.Q,
  r.fix      = Urbanicity.m.cor$TE.fixed,
  r.fix.pval = Urbanicity.m.cor$pval.fixed,
  r.fix.low  = Urbanicity.m.cor$lower.fixed,
  r.fix.up   = Urbanicity.m.cor$upper.fixed,
  r          = Urbanicity.m.cor$TE.random,
  r.pval     = Urbanicity.m.cor$pval.random,
  r.low      = Urbanicity.m.cor$lower.random,
  r.up       = Urbanicity.m.cor$upper.random),
  #
  # Religiosity.m.cor
  #-----------
  cbind(
  Var        = "Religiosity",
  N          = sum(Religiosity.m.cor$n), 
  k          = Religiosity.m.cor$k,
  tau2       = Religiosity.m.cor$tau2,
  I2         = Religiosity.m.cor$I2,
  sig.het    = Religiosity.m.cor$pval.Q,
  r.fix      = Religiosity.m.cor$TE.fixed,
  r.fix.pval = Religiosity.m.cor$pval.fixed,
  r.fix.low  = Religiosity.m.cor$lower.fixed,
  r.fix.up   = Religiosity.m.cor$upper.fixed,
  r          = Religiosity.m.cor$TE.random,
  r.pval     = Religiosity.m.cor$pval.random,
  r.low      = Religiosity.m.cor$lower.random,
  r.up       = Religiosity.m.cor$upper.random),
  #
  # Married.m.cor
  #-----------
  cbind(
  Var        = "Married (vs Single)",
  N          = sum(Married.m.cor$n), 
  k          = Married.m.cor$k,
  tau2       = Married.m.cor$tau2,
  I2         = Married.m.cor$I2,
  sig.het    = Married.m.cor$pval.Q,
  r.fix      = Married.m.cor$TE.fixed,
  r.fix.pval = Married.m.cor$pval.fixed,
  r.fix.low  = Married.m.cor$lower.fixed,
  r.fix.up   = Married.m.cor$upper.fixed,
  r          = Married.m.cor$TE.random,
  r.pval     = Married.m.cor$pval.random,
  r.low      = Married.m.cor$lower.random,
  r.up       = Married.m.cor$upper.random),
  #
  # Employed.m.cor
  #-----------
  cbind(
  Var        = "Employed (vs Retired)",
  N          = sum(Employed.m.cor$n), 
  k          = Employed.m.cor$k,
  tau2       = Employed.m.cor$tau2,
  I2         = Employed.m.cor$I2,
  sig.het    = Employed.m.cor$pval.Q,
  r.fix      = Employed.m.cor$TE.fixed,
  r.fix.pval = Employed.m.cor$pval.fixed,
  r.fix.low  = Employed.m.cor$lower.fixed,
  r.fix.up   = Employed.m.cor$upper.fixed,
  r          = Employed.m.cor$TE.random,
  r.pval     = Employed.m.cor$pval.random,
  r.low      = Employed.m.cor$lower.random,
  r.up       = Employed.m.cor$upper.random),
  #
  ##############################
  # HEADING: Race & Ethnicity #
  ############################
  cbind(
  Var        = "Race & Ethnicity",
  N          = NA, 
  k          = NA,
  tau2       = NA,
  I2         = NA,
  sig.het    = NA,
  r.fix      = NA,
  r.fix.pval = NA,
  r.fix.low  = NA,
  r.fix.up   = NA,
  r          = NA,
  r.pval     = NA,
  r.low      = NA,
  r.up       = NA),
  #
  # Race_Blacks.m.cor
  #-----------
  cbind(
  Var        = "Blacks (vs Other Races)",
  N          = sum(Race_Blacks.m.cor$n), 
  k          = Race_Blacks.m.cor$k,
  tau2       = Race_Blacks.m.cor$tau2,
  I2         = Race_Blacks.m.cor$I2,
  sig.het    = Race_Blacks.m.cor$pval.Q,
  r.fix      = Race_Blacks.m.cor$TE.fixed,
  r.fix.pval = Race_Blacks.m.cor$pval.fixed,
  r.fix.low  = Race_Blacks.m.cor$lower.fixed,
  r.fix.up   = Race_Blacks.m.cor$upper.fixed,
  r          = Race_Blacks.m.cor$TE.random,
  r.pval     = Race_Blacks.m.cor$pval.random,
  r.low      = Race_Blacks.m.cor$lower.random,
  r.up       = Race_Blacks.m.cor$upper.random),
  #
  # Race_Whites.m.cor
  #-----------
  cbind(
  Var        = "Whites (vs Other Races)",
  N          = sum(Race_Whites.m.cor$n), 
  k          = Race_Whites.m.cor$k,
  tau2       = Race_Whites.m.cor$tau2,
  I2         = Race_Whites.m.cor$I2,
  sig.het    = Race_Whites.m.cor$pval.Q,
  r.fix      = Race_Whites.m.cor$TE.fixed,
  r.fix.pval = Race_Whites.m.cor$pval.fixed,
  r.fix.low  = Race_Whites.m.cor$lower.fixed,
  r.fix.up   = Race_Whites.m.cor$upper.fixed,
  r          = Race_Whites.m.cor$TE.random,
  r.pval     = Race_Whites.m.cor$pval.random,
  r.low      = Race_Whites.m.cor$lower.random,
  r.up       = Race_Whites.m.cor$upper.random),
  #
  # Race_Hispanic.m.cor
  #-----------
  cbind(
  Var        = "Hispanics (vs Other Races)",
  N          = sum(Race_Hispanic.m.cor$n), 
  k          = Race_Hispanic.m.cor$k,
  tau2       = Race_Hispanic.m.cor$tau2,
  I2         = Race_Hispanic.m.cor$I2,
  sig.het    = Race_Hispanic.m.cor$pval.Q,
  r.fix      = Race_Hispanic.m.cor$TE.fixed,
  r.fix.pval = Race_Hispanic.m.cor$pval.fixed,
  r.fix.low  = Race_Hispanic.m.cor$lower.fixed,
  r.fix.up   = Race_Hispanic.m.cor$upper.fixed,
  r          = Race_Hispanic.m.cor$TE.random,
  r.pval     = Race_Hispanic.m.cor$pval.random,
  r.low      = Race_Hispanic.m.cor$lower.random,
  r.up       = Race_Hispanic.m.cor$upper.random),
  #
  # Race_Asians.m.cor
  #-----------
  cbind(
  Var        = "Asians (vs Other Races)",
  N          = sum(Race_Asians.m.cor$n), 
  k          = Race_Asians.m.cor$k,
  tau2       = Race_Asians.m.cor$tau2,
  I2         = Race_Asians.m.cor$I2,
  sig.het    = Race_Asians.m.cor$pval.Q,
  r.fix      = Race_Asians.m.cor$TE.fixed,
  r.fix.pval = Race_Asians.m.cor$pval.fixed,
  r.fix.low  = Race_Asians.m.cor$lower.fixed,
  r.fix.up   = Race_Asians.m.cor$upper.fixed,
  r          = Race_Asians.m.cor$TE.random,
  r.pval     = Race_Asians.m.cor$pval.random,
  r.low      = Race_Asians.m.cor$lower.random,
  r.up       = Race_Asians.m.cor$upper.random),
  #
  ####################################
  # HEADING: Partisanship & Ideology #
  ####################################
  cbind(
  Var        = "Partisanship & Ideology",
  N          = NA, 
  k          = NA,
  tau2       = NA,
  I2         = NA,
  sig.het    = NA,
  r.fix      = NA,
  r.fix.pval = NA,
  r.fix.low  = NA,
  r.fix.up   = NA,
  r          = NA,
  r.pval     = NA,
  r.low      = NA,
  r.up       = NA),
  #
  # Partisanship_Rep.m.cor
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Republican (3-point PID)",
  N          = sum(Partisanship_Rep.m.cor$n), 
  k          = Partisanship_Rep.m.cor$k,
  tau2       = Partisanship_Rep.m.cor$tau2,
  I2         = Partisanship_Rep.m.cor$I2,
  sig.het    = Partisanship_Rep.m.cor$pval.Q,
  r.fix      = Partisanship_Rep.m.cor$TE.fixed,
  r.fix.pval = Partisanship_Rep.m.cor$pval.fixed,
  r.fix.low  = Partisanship_Rep.m.cor$lower.fixed,
  r.fix.up   = Partisanship_Rep.m.cor$upper.fixed,
  r          = Partisanship_Rep.m.cor$TE.random,
  r.pval     = Partisanship_Rep.m.cor$pval.random,
  r.low      = Partisanship_Rep.m.cor$lower.random,
  r.up       = Partisanship_Rep.m.cor$upper.random),
  #
  # Ideology.m.cor
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Conservatism (3-point IID)",
  N          = sum(Ideology.m.cor$n), 
  k          = Ideology.m.cor$k,
  tau2       = Ideology.m.cor$tau2,
  I2         = Ideology.m.cor$I2,
  sig.het    = Ideology.m.cor$pval.Q,
  r.fix      = Ideology.m.cor$TE.fixed,
  r.fix.pval = Ideology.m.cor$pval.fixed,
  r.fix.low  = Ideology.m.cor$lower.fixed,
  r.fix.up   = Ideology.m.cor$upper.fixed,
  r          = Ideology.m.cor$TE.random,
  r.pval     = Ideology.m.cor$pval.random,
  r.low      = Ideology.m.cor$lower.random,
  r.up       = Ideology.m.cor$upper.random),
  #
  ##################################################
  # HEADING: Voting Behavior & Political Attitudes #
  ##################################################
  cbind(
  Var        = "Voting Behavior & Political Attitudes",
  N          = NA, 
  k          = NA,
  tau2       = NA,
  I2         = NA,
  sig.het    = NA,
  r.fix      = NA,
  r.fix.pval = NA,
  r.fix.low  = NA,
  r.fix.up   = NA,
  r          = NA,
  r.pval     = NA,
  r.low      = NA,
  r.up       = NA),
  #
  # VoteReg.m.cor | "Registered to vote"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Registered to Vote",
  N          = sum(VoteReg.m.cor$n), 
  k          = VoteReg.m.cor$k,
  tau2       = VoteReg.m.cor$tau2,
  I2         = VoteReg.m.cor$I2,
  sig.het    = VoteReg.m.cor$pval.Q,
  r.fix      = VoteReg.m.cor$TE.fixed,
  r.fix.pval = VoteReg.m.cor$pval.fixed,
  r.fix.low  = VoteReg.m.cor$lower.fixed,
  r.fix.up   = VoteReg.m.cor$upper.fixed,
  r          = VoteReg.m.cor$TE.random,
  r.pval     = VoteReg.m.cor$pval.random,
  r.low      = VoteReg.m.cor$lower.random,
  r.up       = VoteReg.m.cor$upper.random),
  #
  # VoteInt.m.cor | "Intention to vote"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Intention to Vote",
  N          = sum(VoteInt.m.cor$n), 
  k          = VoteInt.m.cor$k,
  tau2       = VoteInt.m.cor$tau2,
  I2         = VoteInt.m.cor$I2,
  sig.het    = VoteInt.m.cor$pval.Q,
  r.fix      = VoteInt.m.cor$TE.fixed,
  r.fix.pval = VoteInt.m.cor$pval.fixed,
  r.fix.low  = VoteInt.m.cor$lower.fixed,
  r.fix.up   = VoteInt.m.cor$upper.fixed,
  r          = VoteInt.m.cor$TE.random,
  r.pval     = VoteInt.m.cor$pval.random,
  r.low      = VoteInt.m.cor$lower.random,
  r.up       = VoteInt.m.cor$upper.random),
  #
  # VoteHR_Republicans.m.cor | "Vote Intention House Representatives (Republicans vs Democrats)"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Vote Intention House Representatives (Republicans vs Democrats)",
  N          = sum(VoteHR_Republicans.m.cor$n), 
  k          = VoteHR_Republicans.m.cor$k,
  tau2       = VoteHR_Republicans.m.cor$tau2,
  I2         = VoteHR_Republicans.m.cor$I2,
  sig.het    = VoteHR_Republicans.m.cor$pval.Q,
  r.fix      = VoteHR_Republicans.m.cor$TE.fixed,
  r.fix.pval = VoteHR_Republicans.m.cor$pval.fixed,
  r.fix.low  = VoteHR_Republicans.m.cor$lower.fixed,
  r.fix.up   = VoteHR_Republicans.m.cor$upper.fixed,
  r          = VoteHR_Republicans.m.cor$TE.random,
  r.pval     = VoteHR_Republicans.m.cor$pval.random,
  r.low      = VoteHR_Republicans.m.cor$lower.random,
  r.up       = VoteHR_Republicans.m.cor$upper.random),
  #
  # Vote2020_TrumpvsBiden.m.cor | "Vote Intention 2020 (Trump vs Biden)"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Trump Vote Intention 2020 (vs Biden)",
  N          = sum(Vote2020_TrumpvsBiden.m.cor$n), 
  k          = Vote2020_TrumpvsBiden.m.cor$k,
  tau2       = Vote2020_TrumpvsBiden.m.cor$tau2,
  I2         = Vote2020_TrumpvsBiden.m.cor$I2,
  sig.het    = Vote2020_TrumpvsBiden.m.cor$pval.Q,
  r.fix      = Vote2020_TrumpvsBiden.m.cor$TE.fixed,
  r.fix.pval = Vote2020_TrumpvsBiden.m.cor$pval.fixed,
  r.fix.low  = Vote2020_TrumpvsBiden.m.cor$lower.fixed,
  r.fix.up   = Vote2020_TrumpvsBiden.m.cor$upper.fixed,
  r          = Vote2020_TrumpvsBiden.m.cor$TE.random,
  r.pval     = Vote2020_TrumpvsBiden.m.cor$pval.random,
  r.low      = Vote2020_TrumpvsBiden.m.cor$lower.random,
  r.up       = Vote2020_TrumpvsBiden.m.cor$upper.random),
  #
  # Vote16_ClintonVSTrump.m.cor | "Vote Intention 2016 (Hillary vs Trump)"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Trump Vote Intention 2016 (vs Clinton)",
  N          = sum(Vote16_ClintonVSTrump.m.cor$n), 
  k          = Vote16_ClintonVSTrump.m.cor$k,
  tau2       = Vote16_ClintonVSTrump.m.cor$tau2,
  I2         = Vote16_ClintonVSTrump.m.cor$I2,
  sig.het    = Vote16_ClintonVSTrump.m.cor$pval.Q,
  r.fix      = Vote16_ClintonVSTrump.m.cor$TE.fixed,
  r.fix.pval = Vote16_ClintonVSTrump.m.cor$pval.fixed,
  r.fix.low  = Vote16_ClintonVSTrump.m.cor$lower.fixed,
  r.fix.up   = Vote16_ClintonVSTrump.m.cor$upper.fixed,
  r          = Vote16_ClintonVSTrump.m.cor$TE.random,
  r.pval     = Vote16_ClintonVSTrump.m.cor$pval.random,
  r.low      = Vote16_ClintonVSTrump.m.cor$lower.random,
  r.up       = Vote16_ClintonVSTrump.m.cor$upper.random),
  #
  # TrumpApp.m.cor | "Approval of Trump's Presidency"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Approval of Trump's Presidency",
  N          = sum(TrumpApp.m.cor$n), 
  k          = TrumpApp.m.cor$k,
  tau2       = TrumpApp.m.cor$tau2,
  I2         = TrumpApp.m.cor$I2,
  sig.het    = TrumpApp.m.cor$pval.Q,
  r.fix      = TrumpApp.m.cor$TE.fixed,
  r.fix.pval = TrumpApp.m.cor$pval.fixed,
  r.fix.low  = TrumpApp.m.cor$lower.fixed,
  r.fix.up   = TrumpApp.m.cor$upper.fixed,
  r          = TrumpApp.m.cor$TE.random,
  r.pval     = TrumpApp.m.cor$pval.random,
  r.low      = TrumpApp.m.cor$lower.random,
  r.up       = TrumpApp.m.cor$upper.random),
  #
  # Obama_App.m.cor | "Approval of Obama's Presidency"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Approval of Obama's Presidency",
  N          = sum(Obama_App.m.cor$n), 
  k          = Obama_App.m.cor$k,
  tau2       = Obama_App.m.cor$tau2,
  I2         = Obama_App.m.cor$I2,
  sig.het    = Obama_App.m.cor$pval.Q,
  r.fix      = Obama_App.m.cor$TE.fixed,
  r.fix.pval = Obama_App.m.cor$pval.fixed,
  r.fix.low  = Obama_App.m.cor$lower.fixed,
  r.fix.up   = Obama_App.m.cor$upper.fixed,
  r          = Obama_App.m.cor$TE.random,
  r.pval     = Obama_App.m.cor$pval.random,
  r.low      = Obama_App.m.cor$lower.random,
  r.up       = Obama_App.m.cor$upper.random),
  #
  # Trump_Fav.m.cor | "Favorability towards Trump"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Favorability towards Trump",
  N          = sum(Trump_Fav.m.cor$n), 
  k          = Trump_Fav.m.cor$k,
  tau2       = Trump_Fav.m.cor$tau2,
  I2         = Trump_Fav.m.cor$I2,
  sig.het    = Trump_Fav.m.cor$pval.Q,
  r.fix      = Trump_Fav.m.cor$TE.fixed,
  r.fix.pval = Trump_Fav.m.cor$pval.fixed,
  r.fix.low  = Trump_Fav.m.cor$lower.fixed,
  r.fix.up   = Trump_Fav.m.cor$upper.fixed,
  r          = Trump_Fav.m.cor$TE.random,
  r.pval     = Trump_Fav.m.cor$pval.random,
  r.low      = Trump_Fav.m.cor$lower.random,
  r.up       = Trump_Fav.m.cor$upper.random),
  #
  # Hillary_Fav.m.cor | "Favorability towards Clinton"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Favorability towards Clinton",
  N          = sum(Hillary_Fav.m.cor$n), 
  k          = Hillary_Fav.m.cor$k,
  tau2       = Hillary_Fav.m.cor$tau2,
  I2         = Hillary_Fav.m.cor$I2,
  sig.het    = Hillary_Fav.m.cor$pval.Q,
  r.fix      = Hillary_Fav.m.cor$TE.fixed,
  r.fix.pval = Hillary_Fav.m.cor$pval.fixed,
  r.fix.low  = Hillary_Fav.m.cor$lower.fixed,
  r.fix.up   = Hillary_Fav.m.cor$upper.fixed,
  r          = Hillary_Fav.m.cor$TE.random,
  r.pval     = Hillary_Fav.m.cor$pval.random,
  r.low      = Hillary_Fav.m.cor$lower.random,
  r.up       = Hillary_Fav.m.cor$upper.random),
  #
  # BidenvsTrump_Race.m.cor | "Biden's Handling of Racial Tensions (vs Trump)"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Biden's Handling of Racial Tensions (vs Trump)",
  N          = sum(BidenvsTrump_Race.m.cor$n), 
  k          = BidenvsTrump_Race.m.cor$k,
  tau2       = BidenvsTrump_Race.m.cor$tau2,
  I2         = BidenvsTrump_Race.m.cor$I2,
  sig.het    = BidenvsTrump_Race.m.cor$pval.Q,
  r.fix      = BidenvsTrump_Race.m.cor$TE.fixed,
  r.fix.pval = BidenvsTrump_Race.m.cor$pval.fixed,
  r.fix.low  = BidenvsTrump_Race.m.cor$lower.fixed,
  r.fix.up   = BidenvsTrump_Race.m.cor$upper.fixed,
  r          = BidenvsTrump_Race.m.cor$TE.random,
  r.pval     = BidenvsTrump_Race.m.cor$pval.random,
  r.low      = BidenvsTrump_Race.m.cor$lower.random,
  r.up       = BidenvsTrump_Race.m.cor$upper.random),
  #
  ##########################################
  # HEADING: Attitudes towards Immigration #
  ##########################################
  cbind(
  Var        = "Attitudes towards Immigration",
  N          = NA, 
  k          = NA,
  tau2       = NA,
  I2         = NA,
  sig.het    = NA,
  r.fix      = NA,
  r.fix.pval = NA,
  r.fix.low  = NA,
  r.fix.up   = NA,
  r          = NA,
  r.pval     = NA,
  r.low      = NA,
  r.up       = NA),
  #
  # MexicoWall.m.cor | "Support for building the wall"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Support for Building the Wall",
  N          = sum(MexicoWall.m.cor$n), 
  k          = MexicoWall.m.cor$k,
  tau2       = MexicoWall.m.cor$tau2,
  I2         = MexicoWall.m.cor$I2,
  sig.het    = MexicoWall.m.cor$pval.Q,
  r.fix      = MexicoWall.m.cor$TE.fixed,
  r.fix.pval = MexicoWall.m.cor$pval.fixed,
  r.fix.low  = MexicoWall.m.cor$lower.fixed,
  r.fix.up   = MexicoWall.m.cor$upper.fixed,
  r          = MexicoWall.m.cor$TE.random,
  r.pval     = MexicoWall.m.cor$pval.random,
  r.low      = MexicoWall.m.cor$lower.random,
  r.up       = MexicoWall.m.cor$upper.random),
  #
  # Immigration_Jobs.m.cor | "Immigrants take jobs away"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Immigrants Take Jobs Away",
  N          = sum(Immigration_Jobs.m.cor$n), 
  k          = Immigration_Jobs.m.cor$k,
  tau2       = Immigration_Jobs.m.cor$tau2,
  I2         = Immigration_Jobs.m.cor$I2,
  sig.het    = Immigration_Jobs.m.cor$pval.Q,
  r.fix      = Immigration_Jobs.m.cor$TE.fixed,
  r.fix.pval = Immigration_Jobs.m.cor$pval.fixed,
  r.fix.low  = Immigration_Jobs.m.cor$lower.fixed,
  r.fix.up   = Immigration_Jobs.m.cor$upper.fixed,
  r          = Immigration_Jobs.m.cor$TE.random,
  r.pval     = Immigration_Jobs.m.cor$pval.random,
  r.low      = Immigration_Jobs.m.cor$lower.random,
  r.up       = Immigration_Jobs.m.cor$upper.random),
  #
    # Immigration_Illegal.m.cor | "Illegal Immigrants should leave the U.S."
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Illegal Immigrants should leave U.S.",
  N          = sum(Immigration_Illegal.m.cor$n), 
  k          = Immigration_Illegal.m.cor$k,
  tau2       = Immigration_Illegal.m.cor$tau2,
  I2         = Immigration_Illegal.m.cor$I2,
  sig.het    = Immigration_Illegal.m.cor$pval.Q,
  r.fix      = Immigration_Illegal.m.cor$TE.fixed,
  r.fix.pval = Immigration_Illegal.m.cor$pval.fixed,
  r.fix.low  = Immigration_Illegal.m.cor$lower.fixed,
  r.fix.up   = Immigration_Illegal.m.cor$upper.fixed,
  r          = Immigration_Illegal.m.cor$TE.random,
  r.pval     = Immigration_Illegal.m.cor$pval.random,
  r.low      = Immigration_Illegal.m.cor$lower.random,
  r.up       = Immigration_Illegal.m.cor$upper.random),
  #
  ##########################################
  # HEADING: Racial Attitudes #
  ##########################################
  cbind(
  Var        = "Racial Attitudes",
  N          = NA, 
  k          = NA,
  tau2       = NA,
  I2         = NA,
  sig.het    = NA,
  r.fix      = NA,
  r.fix.pval = NA,
  r.fix.low  = NA,
  r.fix.up   = NA,
  r          = NA,
  r.pval     = NA,
  r.low      = NA,
  r.up       = NA),
  #
  # PoliceMisconduct.m.cor | "Racially motivated Police Misconduct"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Racially Motivated Police Misconduct",
  N          = sum(PoliceMisconduct.m.cor$n), 
  k          = PoliceMisconduct.m.cor$k,
  tau2       = PoliceMisconduct.m.cor$tau2,
  I2         = PoliceMisconduct.m.cor$I2,
  sig.het    = PoliceMisconduct.m.cor$pval.Q,
  r.fix      = PoliceMisconduct.m.cor$TE.fixed,
  r.fix.pval = PoliceMisconduct.m.cor$pval.fixed,
  r.fix.low  = PoliceMisconduct.m.cor$lower.fixed,
  r.fix.up   = PoliceMisconduct.m.cor$upper.fixed,
  r          = PoliceMisconduct.m.cor$TE.random,
  r.pval     = PoliceMisconduct.m.cor$pval.random,
  r.low      = PoliceMisconduct.m.cor$lower.random,
  r.up       = PoliceMisconduct.m.cor$upper.random),
  #
  # PersDiscr.m.cor | "Experienced discrimination"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Experienced Discrimination",
  N          = sum(PersDiscr.m.cor$n), 
  k          = PersDiscr.m.cor$k,
  tau2       = PersDiscr.m.cor$tau2,
  I2         = PersDiscr.m.cor$I2,
  sig.het    = PersDiscr.m.cor$pval.Q,
  r.fix      = PersDiscr.m.cor$TE.fixed,
  r.fix.pval = PersDiscr.m.cor$pval.fixed,
  r.fix.low  = PersDiscr.m.cor$lower.fixed,
  r.fix.up   = PersDiscr.m.cor$upper.fixed,
  r          = PersDiscr.m.cor$TE.random,
  r.pval     = PersDiscr.m.cor$pval.random,
  r.low      = PersDiscr.m.cor$lower.random,
  r.up       = PersDiscr.m.cor$upper.random),
  #
  # RacialDisc.m.cor | "Blacks are discriminated against"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Blacks Are Discriminated against",
  N          = sum(RacialDisc.m.cor$n), 
  k          = RacialDisc.m.cor$k,
  tau2       = RacialDisc.m.cor$tau2,
  I2         = RacialDisc.m.cor$I2,
  sig.het    = RacialDisc.m.cor$pval.Q,
  r.fix      = RacialDisc.m.cor$TE.fixed,
  r.fix.pval = RacialDisc.m.cor$pval.fixed,
  r.fix.low  = RacialDisc.m.cor$lower.fixed,
  r.fix.up   = RacialDisc.m.cor$upper.fixed,
  r          = RacialDisc.m.cor$TE.random,
  r.pval     = RacialDisc.m.cor$pval.random,
  r.low      = RacialDisc.m.cor$lower.random,
  r.up       = RacialDisc.m.cor$upper.random),
  #
  # SystematicRacism.m.cor | "Perceived Systematic Racism"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Perceived Systematic Racism",
  N          = sum(SystematicRacism.m.cor$n), 
  k          = SystematicRacism.m.cor$k,
  tau2       = SystematicRacism.m.cor$tau2,
  I2         = SystematicRacism.m.cor$I2,
  sig.het    = SystematicRacism.m.cor$pval.Q,
  r.fix      = SystematicRacism.m.cor$TE.fixed,
  r.fix.pval = SystematicRacism.m.cor$pval.fixed,
  r.fix.low  = SystematicRacism.m.cor$lower.fixed,
  r.fix.up   = SystematicRacism.m.cor$upper.fixed,
  r          = SystematicRacism.m.cor$TE.random,
  r.pval     = SystematicRacism.m.cor$pval.random,
  r.low      = SystematicRacism.m.cor$lower.random,
  r.up       = SystematicRacism.m.cor$upper.random),
  #
  # AttendRacialProtest.m.cor | "Racial Equality Protesting"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "Racial Equality Protesting",
  N          = sum(AttendRacialProtest.m.cor$n), 
  k          = AttendRacialProtest.m.cor$k,
  tau2       = AttendRacialProtest.m.cor$tau2,
  I2         = AttendRacialProtest.m.cor$I2,
  sig.het    = AttendRacialProtest.m.cor$pval.Q,
  r.fix      = AttendRacialProtest.m.cor$TE.fixed,
  r.fix.pval = AttendRacialProtest.m.cor$pval.fixed,
  r.fix.low  = AttendRacialProtest.m.cor$lower.fixed,
  r.fix.up   = AttendRacialProtest.m.cor$upper.fixed,
  r          = AttendRacialProtest.m.cor$TE.random,
  r.pval     = AttendRacialProtest.m.cor$pval.random,
  r.low      = AttendRacialProtest.m.cor$lower.random,
  r.up       = AttendRacialProtest.m.cor$upper.random),
  #
    # Protest_Legitimacy.m.cor | "BLM Legitimacy"
  #-------------------------------------------------------------------------
  cbind(
  Var        = "BLM Legitimacy",
  N          = sum(Protest_Legitimacy.m.cor$n), 
  k          = Protest_Legitimacy.m.cor$k,
  tau2       = Protest_Legitimacy.m.cor$tau2,
  I2         = Protest_Legitimacy.m.cor$I2,
  sig.het    = Protest_Legitimacy.m.cor$pval.Q,
  r.fix      = Protest_Legitimacy.m.cor$TE.fixed,
  r.fix.pval = Protest_Legitimacy.m.cor$pval.fixed,
  r.fix.low  = Protest_Legitimacy.m.cor$lower.fixed,
  r.fix.up   = Protest_Legitimacy.m.cor$upper.fixed,
  r          = Protest_Legitimacy.m.cor$TE.random,
  r.pval     = Protest_Legitimacy.m.cor$pval.random,
  r.low      = Protest_Legitimacy.m.cor$lower.random,
  r.up       = Protest_Legitimacy.m.cor$upper.random),
  #
  # RaceRelationsBetter.m.cor | "Race relations are getting better"
  #--------------------------------------------------------------
  cbind(
  Var        = "Race Relations Are Getting Better",
  N          = sum(RaceRelationsBetter.m.cor$n), 
  k          = RaceRelationsBetter.m.cor$k,
  tau2       = RaceRelationsBetter.m.cor$tau2,
  I2         = RaceRelationsBetter.m.cor$I2,
  sig.het    = RaceRelationsBetter.m.cor$pval.Q,
  r.fix      = RaceRelationsBetter.m.cor$TE.fixed,
  r.fix.pval = RaceRelationsBetter.m.cor$pval.fixed,
  r.fix.low  = RaceRelationsBetter.m.cor$lower.fixed,
  r.fix.up   = RaceRelationsBetter.m.cor$upper.fixed,
  r          = RaceRelationsBetter.m.cor$TE.random,
  r.pval     = RaceRelationsBetter.m.cor$pval.random,
  r.low      = RaceRelationsBetter.m.cor$lower.random,
  r.up       = RaceRelationsBetter.m.cor$upper.random),
  ##########################################
  # HEADING: Economic Attitudes            #
  ##########################################
  cbind(
  Var        = "Economic Attitudes",
  N          = NA, 
  k          = NA,
  tau2       = NA,
  I2         = NA,
  sig.het    = NA,
  r.fix      = NA,
  r.fix.pval = NA,
  r.fix.low  = NA,
  r.fix.up   = NA,
  r          = NA,
  r.pval     = NA,
  r.low      = NA,
  r.up       = NA),
  #
  #
  # Country_Economy.m.cor | "U.S. Economy is going well"
  #--------------------------------------------------------------
  cbind(
  Var        = "U.S. Economy is Going Well",
  N          = sum(Country_Economy.m.cor$n), 
  k          = Country_Economy.m.cor$k,
  tau2       = Country_Economy.m.cor$tau2,
  I2         = Country_Economy.m.cor$I2,
  sig.het    = Country_Economy.m.cor$pval.Q,
  r.fix      = Country_Economy.m.cor$TE.fixed,
  r.fix.pval = Country_Economy.m.cor$pval.fixed,
  r.fix.low  = Country_Economy.m.cor$lower.fixed,
  r.fix.up   = Country_Economy.m.cor$upper.fixed,
  r          = Country_Economy.m.cor$TE.random,
  r.pval     = Country_Economy.m.cor$pval.random,
  r.low      = Country_Economy.m.cor$lower.random,
  r.up       = Country_Economy.m.cor$upper.random),
  #
  # CountryFuture.m.cor | "Optimism about U.S. future"
  #--------------------------------------------------------------
  cbind(
  Var        = "Optimism about U.S. Future",
  N          = sum(CountryFuture.m.cor$n), 
  k          = CountryFuture.m.cor$k,
  tau2       = CountryFuture.m.cor$tau2,
  I2         = CountryFuture.m.cor$I2,
  sig.het    = CountryFuture.m.cor$pval.Q,
  r.fix      = CountryFuture.m.cor$TE.fixed,
  r.fix.pval = CountryFuture.m.cor$pval.fixed,
  r.fix.low  = CountryFuture.m.cor$lower.fixed,
  r.fix.up   = CountryFuture.m.cor$upper.fixed,
  r          = CountryFuture.m.cor$TE.random,
  r.pval     = CountryFuture.m.cor$pval.random,
  r.low      = CountryFuture.m.cor$lower.random,
  r.up       = CountryFuture.m.cor$upper.random),
    #
  # PersFinances.m.cor | "Optimism about Personal Finances"
  #--------------------------------------------------------------
  cbind(
  Var        = "Optimism about Personal Finances",
  N          = sum(PersFinances.m.cor$n), 
  k          = PersFinances.m.cor$k,
  tau2       = PersFinances.m.cor$tau2,
  I2         = PersFinances.m.cor$I2,
  sig.het    = PersFinances.m.cor$pval.Q,
  r.fix      = PersFinances.m.cor$TE.fixed,
  r.fix.pval = PersFinances.m.cor$pval.fixed,
  r.fix.low  = PersFinances.m.cor$lower.fixed,
  r.fix.up   = PersFinances.m.cor$upper.fixed,
  r          = PersFinances.m.cor$TE.random,
  r.pval     = PersFinances.m.cor$pval.random,
  r.low      = PersFinances.m.cor$lower.random,
  r.up       = PersFinances.m.cor$upper.random)
))
#
#sapply(dt.Viz, class) unfactor
#
#save(dt.Viz, file = "dt.Viz.RData")
#
df.Viz <- dt.Viz
df.Viz[,c(2:14)]  <- sapply(df.Viz[,c(2:14)], varhandle::unfactor)
df.Viz$Var  <- as.character(df.Viz$Var)
#
#save(df.Viz, file = "df.Viz.RData")
#
```

# Societal Groups and Subgroups

### DV

```{r BLM}
DT1 <- Midterm.Election.W1.final
table(DT1$BLM_supp)
#

DT1$BLM_supp <-  ifelse(DT1$BLM_supp < 3, 0,
                          ifelse(DT1$BLM_supp > 3, 1, NA)) 
#
table(DT1$BLM_supp)
#
#
#
#
DT2 <- Midterm.Election.W3.final
table(DT2$BLM_supp)
#
DT2$BLM_supp <-  ifelse(DT2$BLM_supp < 3, 0,
                          ifelse(DT2$BLM_supp > 3, 1, NA)) 
#
table(DT2$BLM_supp)
#
#
#
DT5 <- CBS.2016.final
table(DT5$BLM_supp)
#
DT5$BLM_supp  <- DT5$BLM_supp -1
#
table(DT5$BLM_supp)
#
#
#
#
DT6 <- CNN.Kaiser.final
table(DT6$BLM_supp)
#

DT6$BLM_supp  <- DT6$BLM_supp -1
#
table(DT6$BLM_supp)
#
#
DT7 <- CNN.NORC.final
table(DT7$BLM_supp)
#
DT7$BLM_supp  <- DT7$BLM_supp -1
#
table(DT7$BLM_supp)

#
#
DT8 <- CNN.NORC.Elections.final
table(DT8$BLM_supp)
#
DT8$BLM_supp  <- DT8$BLM_supp -1
#
table(DT8$BLM_supp)

#
#
DT9 <- Kaiser.2020.final
table(DT9$BLM_supp)
#
DT9$BLM_supp  <- DT9$BLM_supp -1
#
table(DT9$BLM_supp)

#
#
DT11 <- NPR.Aug.final
table(DT11$BLM_supp)
#
DT11$BLM_supp <- DT11$BLM_supp -1
#
table(DT11$BLM_supp)
#
#

DT12 <- NPR.Sep.final
table(DT12$BLM_supp)
#
DT12$BLM_supp <- DT12$BLM_supp -1
#
table(DT12$BLM_supp)

#
#
DT13 <- Pew.2016.final
table(DT13$BLM_supp)
#
DT13$BLM_supp <- ifelse(DT13$BLM_supp < 3, 0,
                          ifelse(DT13$BLM_supp > 3, 1, NA))
#
table(DT13$BLM_supp)

#
#
DT14 <- Pew.W22.final
table(DT14$BLM_supp)
#
table(DT14$BLM_supp)

#
#
DT15 <- Pew.W68.final
table(DT15$BLM_supp)
#
#
DT15$BLM_supp <- ifelse(DT15$BLM_supp < 3, 0,
                          ifelse(DT15$BLM_supp > 3, 1, NA))
#
table(DT15$BLM_supp)


#
#
DT17 <- Washington.Kaiser.final
table(DT17$BLM_supp)
#
DT17$BLM_supp <- DT17$BLM_supp -1
table(DT17$BLM_supp)
#
#
#
```

### IVs - Demographics

```{r RACE & ETHNICITY}

#DT1
#
DT1$RACE_P <- DT1$RACETHNI
#
DT1[DT1$RACE_P %in% c(3,5), "RACE_P"] <- NA
#
DT1$RACE_P <- as.numeric(DT1$RACE_P)
DT1$RACE_P <- car::recode(DT1$RACE_P, ' "4"="3"; "6"="4"')
#
table(DT1$RACETHNI)
table(DT1$RACE_P)
#
#
#DT2
#
DT2$RACE_P <- DT2$RACETHNI
#
DT2[DT2$RACE_P %in% c(3,5), "RACE_P"] <- NA
#
DT2$RACE_P <- as.numeric(DT2$RACE_P)
DT2$RACE_P <- car::recode(DT2$RACE_P, ' "4"="3"; "6"="4"')
#
table(DT2$RACETHNI)
table(DT2$RACE_P)
#
#
#DT5
#
DT5$RACE_P <- DT5$RACEETH
#
DT5[DT5$RACE_P %in% c(4,9), "RACE_P"] <- NA
#
table(DT5$RACEETH)
table(DT5$RACE_P)
#
#
#DT6
#
DT6$RACE_P <- DT6$RACEVAR
#
DT6[DT6$RACE_P %in% c(4,6,7), "RACE_P"] <- NA
#
DT6$RACE_P <- as.numeric(DT6$RACE_P)
DT6$RACE_P <- car::recode(DT6$RACE_P, ' "2"="1";"3"="2";"1"="3";"5"="4"')
#
table(DT6$RACEVAR)
table(DT6$RACE_P)
#
#
#DT7
#
DT7$RACE_P <- DT7$RACE1
#
DT7[DT7$RACE_P %in% c(5,9), "RACE_P"] <- NA
#
table(DT7$RACE1)
table(DT7$RACE_P)
#
#
#DT8
#
DT8$RACE_P <- DT8$RACE1
#
DT8[DT8$RACE_P %in% c(5,9), "RACE_P"] <- NA
#
table(DT8$RACE1)
table(DT8$RACE_P)
#
#
#DT9
#
DT9$RACE_P <- DT9$RACETHN
#
DT9[DT9$RACE_P %in% c(4,9), "RACE_P"] <- NA
#
table(DT9$RACETHN)
table(DT9$RACE_P)
#
#
#DT11
#
DT11$RACE_P <- DT11$RACET
#
DT11[DT11$RACE_P %in% c(500,600,9300,9700,9900), "RACE_P"] <- NA
#
DT11$RACE_P <- as.numeric(DT11$RACE_P)
DT11$RACE_P <- car::recode(DT11$RACE_P, '"100"="1";"200"="2";"300"="3";"400"="4"')
#
table(DT11$RACET)
table(DT11$RACE_P)
#
#
#DT12
#
DT12$RACE_P <- DT12$RACET
#
DT12[DT12$RACE_P %in% c(500,600,9300,9700,9900), "RACE_P"] <- NA
#
DT12$RACE_P <- as.numeric(DT12$RACE_P)
DT12$RACE_P <- car::recode(DT12$RACE_P, '"100"="1";"200"="2";"300"="3";"400"="4"')
#
table(DT12$RACET)
table(DT12$RACE_P)
#
#
#DT3
#
DT13$RACE_P <- DT13$RACETHN
#
DT13[DT13$RACE_P %in% c(4,9), "RACE_P"] <- NA
#
table(DT13$RACETHN)
table(DT13$RACE_P)
#
#
#DT14
#
DT14$RACE_P <- DT14$F_RACETH
#
DT14[DT14$RACE_P %in% c(4,9), "RACE_P"] <- NA
#
table(DT14$F_RACETH)
table(DT14$RACE_P)
#
#
#DT15
#
DT15$RACE_P <- DT15$F_RACETHNMOD
#
DT15[DT15$RACE_P %in% c(4,99), "RACE_P"] <- NA
#
DT15$RACE_P <- as.numeric(DT15$RACE_P)
DT15$RACE_P <- car::recode(DT15$RACE_P, '"5"="4"')
#
table(DT15$F_RACETHNMOD)
table(DT15$RACE_P)
#
#
#DT17
#
DT17$RACE_P <- DT17$RACETHN
#
DT17[DT17$RACE_P %in% c(4,9), "RACE_P"] <- NA
#
table(DT17$RACETHN)
table(DT17$RACE_P)
#
#
#
#

```


```{r GENDER}

#DT1
#
DT1$GENDER_P <- DT1$RGender
#
table(DT1$RGender)
table(DT1$GENDER_P)
#
#
#DT2
#
DT2$GENDER_P <- DT2$RGender
#
table(DT2$RGender)
table(DT2$GENDER_P)
#
#
#DT5
#
DT5$GENDER_P <- DT5$RGender
#
table(DT5$RGender)
table(DT5$GENDER_P)
#
#
#DT6
#
DT6$GENDER_P <- DT6$RGender
#
table(DT6$RGender)
table(DT6$GENDER_P)
#
#
#DT7
#
DT7$GENDER_P <- DT7$RGender
#
table(DT7$RGender)
table(DT7$GENDER_P)
#
#
#DT8
#
DT8$GENDER_P <- DT8$RGender
#
table(DT8$RGender)
table(DT8$GENDER_P)
#
#
#DT9
#
DT9$GENDER_P <- DT9$RGender
#
table(DT9$RGender)
table(DT9$GENDER_P)
#
#
#DT11
#
DT11$GENDER_P <- DT11$RGender
#
table(DT11$RGender)
table(DT11$GENDER_P)
#
#
#DT12
#
DT12$GENDER_P <- DT12$RGender
#
table(DT12$RGender)
table(DT12$GENDER_P)
#
#
#DT3
#
DT13$GENDER_P <- DT13$RGender
#
table(DT13$RGender)
table(DT13$GENDER_P)
#
#
#DT14
#
DT14$GENDER_P <- DT14$RGender
#
table(DT14$RGender)
table(DT14$GENDER_P)
#
#
#DT15
#
DT15$GENDER_P <- DT15$RGender
#
table(DT15$RGender)
table(DT15$GENDER_P)
#
#
#DT17
#
DT17$GENDER_P <- DT17$RGender
#
table(DT17$RGender)
table(DT17$GENDER_P)
#
#
#
#

```


```{r AGE}

#DT1 - Open Answer
#
DT1$AGE_P <- DT1$RAge
#
DT1$AGE_P <- ifelse(DT1$AGE_P <= 29, 1,
                    ifelse(DT1$AGE_P <= 49 & DT1$AGE_P > 29, 2,
                           ifelse(DT1$AGE_P <= 64 & DT1$AGE_P > 50, 3, 4)))
#
table(DT1$RAge)
table(DT1$AGE_P)
#
#
#DT2 - Open Answer
#
DT2$AGE_P <- DT2$AGE
#
DT2$AGE_P <- ifelse(DT2$AGE_P <= 29, 1,
                    ifelse(DT2$AGE_P <= 49 & DT2$AGE_P > 29, 2,
                           ifelse(DT2$AGE_P <= 64 & DT2$AGE_P > 50, 3, 4)))
#
table(DT2$RAge)
table(DT2$AGE_P)
#
#
#DT5 - Open Answer
#
DT5$AGE_P <- DT5$RAge
#
DT5$AGE_P <- ifelse(DT5$AGE_P <= 29, 1,
                    ifelse(DT5$AGE_P <= 49 & DT5$AGE_P > 29, 2,
                           ifelse(DT5$AGE_P <= 64 & DT5$AGE_P > 50, 3, 4)))
#
table(DT5$RAge)
table(DT5$AGE_P)
#
#
#DT6
#
DT6$AGE_P <- DT6$RAge
#
#
table(DT6$RAge)
table(DT6$AGE_P)
#
#
#DT7
#
DT7$AGE_P <- DT7$RAge
#
table(DT7$RAge)
table(DT7$AGE_P)
#
#
#DT8
#
DT8$AGE_P <- DT8$RAge
#
table(DT8$RAge)
table(DT8$AGE_P)
#
#
#DT9 - Open Answer
#
DT9$AGE_P <- DT9$RAge
#
DT9$AGE_P <- ifelse(DT9$AGE_P <= 29, 1,
                    ifelse(DT9$AGE_P <= 49 & DT9$AGE_P > 29, 2,
                           ifelse(DT9$AGE_P <= 64 & DT9$AGE_P > 50, 3, 4)))
#
table(DT9$RAge)
table(DT9$AGE_P)
#
#
#DT11
#
DT11$AGE_P <- DT11$RAge
#
DT11[DT11$AGE_P %in% c(2,3,4), "AGE_P"] <- NA
#
table(DT11$RAge)
table(DT11$AGE_P)
#
#
#DT12
#
DT12$AGE_P <- DT12$RAge
#
DT12[DT12$AGE_P %in% c(2,3,4), "AGE_P"] <- NA
#
table(DT12$RAge)
table(DT12$AGE_P)
#
#
#DT3 - Open Answer
#
DT13$AGE_P <- DT13$RAge
#
DT13$AGE_P <- ifelse(DT13$AGE_P <= 29, 1,
                    ifelse(DT13$AGE_P <= 49 & DT13$AGE_P > 29, 2,
                           ifelse(DT13$AGE_P <= 64 & DT13$AGE_P > 50, 3, 4)))
#
table(DT13$RAge)
table(DT13$AGE_P)
#
#
#DT14
#
DT14$AGE_P <- DT14$RAge
#
table(DT14$RAge)
table(DT14$AGE_P)
#
#
#DT15
#
DT15$AGE_P <- DT15$RAge
#
table(DT15$RAge)
table(DT15$AGE_P)
#
#
#DT17 - Open Answer
#
DT17$AGE_P <- DT17$RAge
#
DT17$AGE_P <- ifelse(DT17$AGE_P <= 29, 1,
                    ifelse(DT17$AGE_P <= 49 & DT17$AGE_P > 29, 2,
                           ifelse(DT17$AGE_P <= 64 & DT17$AGE_P > 50, 3, 4)))
#
table(DT17$RAge)
table(DT17$AGE_P)
#
#
#

```


```{r EDUCATION}

#DT1
#
DT1$EDUCATION_P <- DT1$REducation
#
DT1$EDUCATION_P <- as.numeric(DT1$EDUCATION_P)
DT1$EDUCATION_P <- car::recode(DT1$EDUCATION_P, ' "2"="1"; "3"="1"; "4"="1"; "5"="1"; "6"="1"; "7"="1"; "8"="1"; "9"="2";"10"="3";"11"="3";"12"="4";"13"="5";"14"="5"')
#
table(DT1$REducation)
table(DT1$EDUCATION_P)
#
#
#
#DT2
#
DT2$EDUCATION_P <- DT2$REducation
#
#
DT2$EDUCATION_P <- as.numeric(DT2$EDUCATION_P)
DT2$EDUCATION_P <- car::recode(DT2$EDUCATION_P, ' "2"="1"; "3"="1"; "4"="1"; "5"="1"; "6"="1"; "7"="1"; "8"="1"; "9"="2";"10"="3";"11"="3";"12"="4";"13"="5";"14"="5"')
#
table(DT2$REducation)
table(DT2$EDUCATION_P)
#
#
#
#DT5
#
DT5$EDUCATION_P <- DT5$REducation
#
table(DT5$REducation)
table(DT5$EDUCATION_P)
#
#
#
#DT6
#
DT6$EDUCATION_P <- DT6$QND11
#
DT6[DT6$EDUCATION_P %in% c(8,9), "EDUCATION_P"] <- NA
#
DT6$EDUCATION_P <- as.numeric(DT6$EDUCATION_P)
DT6$EDUCATION_P <- car::recode(DT6$EDUCATION_P, ' "6"="3"')
#
table(DT6$QND11)
table(DT6$EDUCATION_P)
#
#
#
#DT7
#
DT7$EDUCATION_P <- DT7$REducation
#
DT7$EDUCATION_P <- as.numeric(DT7$EDUCATION_P)
DT7$EDUCATION_P <- car::recode(DT7$EDUCATION_P, ' "2"="1"; "3"="2"; "4"="3"; "5"="3"; "6"="4"; "7"="5"')
#
table(DT7$REducation)
table(DT7$EDUCATION_P)
#
#
#
#DT8
#
DT8$EDUCATION_P <- DT8$REducation
#
#
DT8$EDUCATION_P <- as.numeric(DT8$EDUCATION_P)
DT8$EDUCATION_P <- car::recode(DT8$EDUCATION_P, ' "2"="1"; "3"="2"; "4"="3"; "5"="3"; "6"="4"; "7"="5"')
#
table(DT8$REducation)
table(DT8$EDUCATION_P)
#
#
#
#DT9
#
DT9$EDUCATION_P <- DT9$REducation
#
DT9$EDUCATION_P <- as.numeric(DT9$EDUCATION_P)
DT9$EDUCATION_P <- car::recode(DT9$EDUCATION_P, ' "2"="1"; "3"="2"; "4"="3"; "5"="3"; "6"="4"; "7"="5"; "8"="5"')
#
table(DT9$REducation)
table(DT9$EDUCATION_P)
#
#
#
#DT11
#
DT11$EDUCATION_P <- DT11$REducation
#
DT11[DT11$EDUCATION_P %in% c(1), "EDUCATION_P"] <- NA
#
DT11$EDUCATION_P <- as.numeric(DT11$EDUCATION_P)
DT11$EDUCATION_P <- car::recode(DT11$EDUCATION_P, ' "2"="4"')
#
table(DT11$REducation)
table(DT11$EDUCATION_P)
#
#
#
#DT12
#
DT12$EDUCATION_P <- DT12$REducation
#
DT12[DT12$EDUCATION_P %in% c(1), "EDUCATION_P"] <- NA
#
DT12$EDUCATION_P <- as.numeric(DT12$EDUCATION_P)
DT12$EDUCATION_P <- car::recode(DT12$EDUCATION_P, ' "2"="4"')
#
table(DT12$REducation)
table(DT12$EDUCATION_P)
#
#
#
#DT3
#
DT13$EDUCATION_P <- DT13$REducation
#
DT13$EDUCATION_P <- as.numeric(DT13$EDUCATION_P)
DT13$EDUCATION_P <- car::recode(DT13$EDUCATION_P, ' "2"="1"; "3"="2"; "4"="3"; "5"="3"; "6"="4"; "7"="5"; "8"="5"')
#
table(DT13$REducation)
table(DT13$EDUCATION_P)
#
#
#
#DT14
#
DT14$EDUCATION_P <- DT14$REducation
#
DT14$EDUCATION_P <- as.numeric(DT14$EDUCATION_P)
DT14$EDUCATION_P <- car::recode(DT14$EDUCATION_P, ' "4"="3"; "5"="4"; "6"="5"')
#
table(DT14$REducation)
table(DT14$EDUCATION_P)
#
#
#
#DT15
#
DT15$EDUCATION_P <- DT15$REducation
#
DT15$EDUCATION_P <- as.numeric(DT15$EDUCATION_P)
DT15$EDUCATION_P <- car::recode(DT15$EDUCATION_P, ' "4"="3"; "5"="4"; "6"="5"')
#
table(DT15$REducation)
table(DT15$EDUCATION_P)
#
#
#
#DT17
#
DT17$EDUCATION_P <- DT17$QND12
#
DT17[DT17$EDUCATION_P %in% c(8,9), "EDUCATION_P"] <- NA
#
DT17$EDUCATION_P <- as.numeric(DT17$EDUCATION_P)
DT17$EDUCATION_P <- car::recode(DT17$EDUCATION_P, ' "6"="3"')
#
table(DT17$QND12)
table(DT17$EDUCATION_P)
#
#
#

```


```{r URBANICITY}

#DT1
#
DT1$URBANICITY_P <- DT1$Urbanicity
#
table(DT1$Urbanicity)
table(DT1$URBANICITY_P)
#
#
#DT2
#
DT2$URBANICITY_P <- DT2$Urbanicity
#
table(DT2$Urbanicity)
table(DT2$URBANICITY_P)
#
#
#DT5
#
DT5$URBANICITY_P <- NA
#
#
#DT6
#
DT6$URBANICITY_P <- NA
#
#
#DT7
#
DT7$URBANICITY_P <- DT7$Urbanicity
#
DT7$URBANICITY_P <- as.numeric(DT7$URBANICITY_P)
DT7$URBANICITY_P <- car::recode(DT7$URBANICITY_P, ' "1"="0"; "2"="1"; "3"="1"')
#
table(DT7$Urbanicity)
table(DT7$URBANICITY_P)
#
#
#
#DT8
#
DT8$URBANICITY_P <- DT8$Urbanicity
#
DT8$URBANICITY_P <- as.numeric(DT8$URBANICITY_P)
DT8$URBANICITY_P <- car::recode(DT8$URBANICITY_P, ' "1"="0"; "2"="1"; "3"="1"')
#
table(DT8$Urbanicity)
table(DT8$URBANICITY_P)
#
#
#
#DT9
#
DT9$URBANICITY_P <- NA
#
#
#DT11
#
DT11$URBANICITY_P <- DT11$Urbanicity
#
DT11$URBANICITY_P <- as.numeric(DT11$URBANICITY_P)
DT11$URBANICITY_P <- car::recode(DT11$URBANICITY_P, ' "5"="0"; "2"="1"; "3"="1"; "4"="1"')
#
table(DT11$Urbanicity)
table(DT11$URBANICITY_P)
#
#
#DT12
#
DT12$URBANICITY_P <- DT12$Urbanicity
#
DT12$URBANICITY_P <- as.numeric(DT12$URBANICITY_P)
DT12$URBANICITY_P <- car::recode(DT12$URBANICITY_P, ' "5"="0"; "2"="1"; "3"="1"; "4"="1"')
#
table(DT12$Urbanicity)
table(DT12$URBANICITY_P)
#
#
#DT13
#
DT13$URBANICITY_P <- NA
#
#
#DT14
#
DT14$URBANICITY_P <- NA
#
#
#DT15
#
DT15$URBANICITY_P <- DT15$F_METRO
#
DT15$URBANICITY_P <- as.numeric(DT15$URBANICITY_P)
DT15$URBANICITY_P <- car::recode(DT15$URBANICITY_P, ' "2"="0"')
#
table(DT15$F_METRO)
table(DT15$URBANICITY_P)
#
#
#DT17
#
DT17$URBANICITY_P <- DT17$Urbanicity
#
DT17$URBANICITY_P <- as.numeric(DT17$URBANICITY_P)
DT17$URBANICITY_P <- car::recode(DT17$URBANICITY_P, ' "1"="0"; "2"="1"; "3"="1"')
#
table(DT17$Urbanicity)
table(DT17$URBANICITY_P)
#
#
#

```


```{r RELIGION}
#DT1
#
DT1$RELIGION_P <- NA
#
#
#DT2
#
DT2$RELIGION_P <- NA
#
#
#DT5
#
DT5$RELIGION_P <- NA
#
#
#DT6
#
DT6$RELIGION_P <- NA
#
#
#DT7
#
DT7$RELIGION_P <- DT7$RELIGION
#
table(DT7$RELIGION)
#
DT7[DT7$RELIGION_P %in% c(9), "RELIGION_P"] <- NA
#
table(DT7$RELIGION_P)
#
#
#DT8
#
DT8$RELIGION_P <- NA
#
#
#DT9
#
DT9$RELIGION_P <- NA
#
#
#DT11
#
DT11$RELIGION_P <- NA
#
#
#DT12
#
DT12$RELIGION_P <- NA
#
#
#DT3
#
DT13$RELIGION_P <- DT13$RELIG
#
table(DT13$RELIG)
#
# 1   PROT
# 2   CATH
# 3 JEWISH
# 4  OTHER
# 5   NONE
#
DT13[DT13$RELIGION_P %in% c(13,99), "RELIGION_P"] <- NA
#
DT13$RELIGION_P <- as.numeric(DT13$RELIGION_P)
DT13$RELIGION_P <- car::recode(DT13$RELIGION_P, '  "5"="3";                                                                                                                 "3"="4"; "6"="4"; "7"="4";"8"="4";                                                                                       "9"="5"; "10"="5"; "12"="5";                                                                                             "11"="4"; "14"="4"  ')
#
table(DT13$RELIG)
table(DT13$RELIGION_P)
#
#
#DT14
#
DT14$RELIGION_P <- DT14$F_RELIG_
#
DT14[DT14$RELIGION_P %in% c(13,99), "RELIGION_P"] <- NA
#
DT14$RELIGION_P <- as.numeric(DT14$RELIGION_P)
DT14$RELIGION_P <- car::recode(DT14$RELIGION_P, '  "5"="3";                                                                                                                 "3"="4"; "6"="4"; "7"="4";"8"="4";                                                                                       "9"="5"; "10"="5"; "12"="5";                                                                                             "11"="4"; "14"="4"  ')
table(DT14$F_RELIG_)
table(DT14$RELIGION_P)
#
#
#DT15
#
DT15$RELIGION_P <- DT15$F_RELIG
#
DT15[DT15$RELIGION_P %in% c(99), "RELIGION_P"] <- NA
#
DT15$RELIGION_P <- as.numeric(DT15$RELIGION_P)
DT15$RELIGION_P <- car::recode(DT15$RELIGION_P, '  "5"="3";                                                                                                                 "3"="4"; "6"="4"; "7"="4";"8"="4";                                                                                       "9"="5"; "10"="5"; "12"="5";                                                                                             "11"="4"    ')
#
table(DT15$F_RELIG)
table(DT15$RELIGION_P)
#
#
#DT17
#
DT17$RELIGION_P <- NA
#
#
#
```


```{r MARITAL STATUS}

#DT1
#
DT1$MARITAL_P <- DT1$MARITAL
#
DT1$MARITAL_P <- as.numeric(DT1$MARITAL_P)
DT1$MARITAL_P <- car::recode(DT1$MARITAL_P, ' "6"="5"; "5"="6" ')
#
#
table(DT1$MARITAL)
table(DT1$MARITAL_P)
#
#
#DT2
#
DT2$MARITAL_P <- DT2$MARITAL
#
DT2$MARITAL_P <- as.numeric(DT2$MARITAL_P)
DT2$MARITAL_P <- car::recode(DT2$MARITAL_P, ' "6"="5"; "5"="6" ')
#
table(DT2$MARITAL)
table(DT2$MARITAL_P)
#
#
#DT5
#
DT5$MARITAL_P <- DT5$MARR
#
DT5[DT5$MARITAL_P %in% c(9), "MARITAL_P"] <- NA
#
DT5$MARITAL_P <- as.numeric(DT5$MARITAL_P)
DT5$MARITAL_P <- car::recode(DT5$MARITAL_P, ' "5"="6"')
#
table(DT5$MARR)
table(DT5$MARITAL_P)
#
#
#DT6
#
DT6$MARITAL_P <- DT6$QND5
#
#
DT6[DT6$MARITAL_P %in% c(9), "MARITAL_P"] <- NA
#
DT6$MARITAL_P <- as.numeric(DT6$MARITAL_P)
DT6$MARITAL_P <- car::recode(DT6$MARITAL_P, ' "3"="1"; "5"="2"; "6"="3"; "2"="5"; "1"="6"')
#
table(DT6$QND5)
table(DT6$MARITAL_P)
#
#
#DT7
#
DT7$MARITAL_P <- DT7$MARITAL
#
DT7[DT7$MARITAL_P %in% c(9), "MARITAL_P"] <- NA
#
DT7$MARITAL_P <- as.numeric(DT7$MARITAL_P)
DT7$MARITAL_P <- car::recode(DT7$MARITAL_P, ' "6"="2"; "4"="3"; "5"="4"; "2"="5"; "3"="6"')
#
table(DT7$MARITAL)
table(DT7$MARITAL_P)
#
#
#DT8
#
DT8$MARITAL_P <- NA
#
#
#DT9
#
DT9$MARITAL_P <- DT9$MARITAL
#
DT9[DT9$MARITAL_P %in% c(8,9), "MARITAL_P"] <- NA
#
DT9$MARITAL_P <- as.numeric(DT9$MARITAL_P)
DT9$MARITAL_P <- car::recode(DT9$MARITAL_P, ' "3"="2"; "4"="3"; "5"="4"; "2"="5" ')
#
table(DT9$MARITAL)
table(DT9$MARITAL_P)
#
#
#DT11
#
DT11$MARITAL_P <- NA
#
#
#DT12
#
DT12$MARITAL_P <- NA
#
#
#DT13
#
DT13$MARITAL_P <- DT13$MARITAL
#
DT13[DT13$MARITAL_P %in% c(9), "MARITAL_P"] <- NA
#
DT13$MARITAL_P <- as.numeric(DT13$MARITAL_P)
DT13$MARITAL_P <- car::recode(DT13$MARITAL_P, ' "5"="2"; "2"="5"')
#
table(DT13$MARITAL)
table(DT13$MARITAL_P)
#
#
#DT14
#
DT14$MARITAL_P <- NA
#
#
#DT15
#
DT15$MARITAL_P <- DT15$F_MARITAL
#
DT15[DT15$MARITAL_P %in% c(99), "MARITAL_P"] <- NA
#
DT15$MARITAL_P <- as.numeric(DT15$MARITAL_P)
DT15$MARITAL_P <- car::recode(DT15$MARITAL_P, ' "5"="2"; "2"="5"')
#
table(DT15$F_MARITAL)
table(DT15$MARITAL_P)
#
#
#DT17
#
DT17$MARITAL_P <- DT17$MARITAL
#
DT17[DT17$MARITAL_P %in% c(9), "MARITAL_P"] <- NA
#
#
DT17$MARITAL_P <- as.numeric(DT17$MARITAL_P)
DT17$MARITAL_P <- car::recode(DT17$MARITAL_P, ' "3"="2"; "4"="3"; "5"="4"; "2"="5" ')
#
#
table(DT17$MARITAL)
table(DT17$MARITAL_P)
#
#

```


```{r EMPLOYMENT STATUS}

#DT1
#
DT1$EMPLOYMENT_P <- DT1$EMPLOY
#
DT1$EMPLOYMENT_P <- as.numeric(DT1$EMPLOYMENT_P)
DT1$EMPLOYMENT_P <- car::recode(DT1$EMPLOYMENT_P, ' "2"="1"; "3"="2"; "4"="2"; "7"="2"; "6"="3"; "5"="4" ')
#
table(DT1$EMPLOY)
table(DT1$EMPLOYMENT_P)
#
#
#DT2
#
DT2$EMPLOYMENT_P <- DT2$EMPLOY
#
DT2$EMPLOYMENT_P <- as.numeric(DT2$EMPLOYMENT_P)
DT2$EMPLOYMENT_P <- car::recode(DT2$EMPLOYMENT_P, ' "2"="1"; "3"="2"; "4"="2"; "7"="2"; "6"="3"; "5"="4" ')
#
table(DT2$EMPLOY)
table(DT2$EMPLOYMENT_P)
#
#
#
#DT5
#
DT5$EMPLOYMENT_P <- NA
#
#
#DT6
#
DT6$EMPLOYMENT_P <- DT6$QN4
#
#
DT6[DT6$EMPLOYMENT_P %in% c(5, 8, 98, 99), "EMPLOYMENT_P"] <- NA#
#
DT6$EMPLOYMENT_P <- as.numeric(DT6$EMPLOYMENT_P)
DT6$EMPLOYMENT_P <- car::recode(DT6$EMPLOYMENT_P, ' "2"="1"; "3"="2"; "4"="2"; "7"="3"; "6"="4"')
#
table(DT6$QN4)
table(DT6$EMPLOYMENT_P)
#
#
#
#DT7
#
DT7$EMPLOYMENT_P <- NA
#
#
#DT8
#
DT8$EMPLOYMENT_P <- NA
#
#
#DT9
#
DT9$EMPLOYMENT_P <- DT9$EMPLOY
#
DT9[DT9$EMPLOYMENT_P %in% c(5, 8, 98, 99), "EMPLOYMENT_P"] <- NA#
#
DT9$EMPLOYMENT_P <- as.numeric(DT9$EMPLOYMENT_P)
DT9$EMPLOYMENT_P <- car::recode(DT9$EMPLOYMENT_P, ' "2"="1"; "3"="2"; "4"="2"; "7"="3"; "6"="4"')
#
table(DT9$EMPLOY)
table(DT9$EMPLOYMENT_P)
#
#
#
#DT11
#
DT11$EMPLOYMENT_P <- NA
#
#
#DT12
#
DT12$EMPLOYMENT_P <- NA
#
#
#DT3
#
DT13$EMPLOYMENT_P <- DT13$QE3
#
#
#
DT13$EMPLOYMENT_P <- as.numeric(DT13$EMPLOYMENT_P)
DT13$EMPLOYMENT_P <- car::recode(DT13$EMPLOYMENT_P, ' "2"="1"; "3"="2"; "4"="3"; "5"="4" ')
#
DT13[DT13$EMPLOYMENT_P %in% c(9), "EMPLOYMENT_P"] <- NA
#
table(DT13$QE3)
table(DT13$EMPLOYMENT_P)
#
#
#
#DT14
#
DT14$EMPLOYMENT_P <- NA
#
#
#DT15
#
DT15$EMPLOYMENT_P <- NA
#
#
#DT17
#
DT17$EMPLOYMENT_P <- NA
#
#
```


```{r INCOME}

#DT1
#
DT1$INCOME_P <- DT1$INCOME
#
DT1$INCOME_P <- as.numeric(DT1$INCOME_P)
DT1$INCOME_P <- car::recode(DT1$INCOME_P, ' "2"="1"; "3"="1"; "4"="1"; "5"="1"; "6"="1"; "7"="2"; "8"="2"; "9"="2"; "10"="3"; "11"="3"; "12"="4"; "13"="4"; "14"="4"; "15"="4"; "16"="4"; "17"="4"; "18"="4"')
#
table(DT1$INCOME)
table(DT1$INCOME_P)
#
#
#DT2
#
DT2$INCOME_P <- DT2$INCOME
#
DT2$INCOME_P <- as.numeric(DT2$INCOME_P)
DT2$INCOME_P <- car::recode(DT2$INCOME_P, ' "2"="1"; "3"="1"; "4"="1"; "5"="1"; "6"="1"; "7"="2"; "8"="2"; "9"="2"; "10"="3"; "11"="3"; "12"="4"; "13"="4"; "14"="4"; "15"="4"; "16"="4"; "17"="4"; "18"="4"')
#
table(DT2$INCOME)
table(DT2$INCOME_P)
#
#
#DT5
#
DT5$INCOME_P <- NA
#
#
#DT6
#
DT6$INCOME_P <- DT6$HIncome
#
DT6$INCOME_P <- as.numeric(DT6$INCOME_P)
DT6$INCOME_P <- car::recode(DT6$INCOME_P, ' "2"="1"; "3"="2"; "4"="2"; "5"="3"; "6"="4"; "7"="4"; "8"="4" ')
#
table(DT6$HIncome)
table(DT6$INCOME_P)
#
#
#DT7
#
DT7$INCOME_P <- DT7$HIncome
#
DT7$INCOME_P <- as.numeric(DT7$INCOME_P)
DT7$INCOME_P <- car::recode(DT7$INCOME_P, ' "2"="1"; "3"="2"; "4"="3"; "5"="4"')
#
table(DT7$HIncome)
table(DT7$INCOME_P)
#
#
#DT8
#
DT8$INCOME_P <- DT8$HIncome
#
DT8$INCOME_P <- as.numeric(DT8$INCOME_P)
DT8$INCOME_P <- car::recode(DT8$INCOME_P, ' "2"="1"; "3"="2"; "4"="3"; "5"="4"')
#
table(DT8$HIncome)
table(DT8$INCOME_P)
#
#
#DT9
#
DT9$INCOME_P <- DT9$HIncome
#
DT9$INCOME_P <- as.numeric(DT9$INCOME_P)
DT9$INCOME_P <- car::recode(DT9$INCOME_P, ' "2"="1"; "3"="2"; "4"="2"; "5"="3"; "6"="4"; "7"="4"; "8"="4" ')
#
table(DT9$HIncome)
table(DT9$INCOME_P)
#
#
#DT11
#
DT11$INCOME_P <- DT11$HIncome
#
DT11[DT11$INCOME_P %in% c(1,2,3,4), "INCOME_P"] <- NA
#
DT11$INCOME_P <- as.numeric(DT11$INCOME_P)
DT11$INCOME_P <- car::recode(DT11$INCOME_P, ' "5"="4"; "6"="4"')
#
table(DT11$HIncome)
table(DT11$INCOME_P)
#
#
#DT12
#
DT12$INCOME_P <- DT12$HIncome
#
DT12[DT12$INCOME_P %in% c(1,2,3,4), "INCOME_P"] <- NA
#
DT12$INCOME_P <- as.numeric(DT12$INCOME_P)
DT12$INCOME_P <- car::recode(DT12$INCOME_P, ' "5"="4"; "6"="4"')
#
table(DT12$HIncome)
table(DT12$INCOME_P)
#
#
#DT3
#
DT13$INCOME_P <- DT13$HIncome
#
DT13$INCOME_P <- as.numeric(DT13$INCOME_P)
DT13$INCOME_P <- car::recode(DT13$INCOME_P, ' "2"="1"; "3"="1"; "4"="2"; "5"="2"; "6"="3"; "7"="4"; "8"="4"; "9"="4"')
#
table(DT13$HIncome)
table(DT13$INCOME_P)
#
#
#DT14
#
DT14$INCOME_P <- DT14$HIncome
#
DT14$INCOME_P <- as.numeric(DT14$INCOME_P)
DT14$INCOME_P <- car::recode(DT14$INCOME_P, ' "2"="1"; "3"="1"; "4"="2"; "5"="2"; "6"="3"; "7"="4"; "8"="4"; "9"="4"')
#
table(DT14$HIncome)
table(DT14$INCOME_P)
#
#
#DT15
#
DT15$INCOME_P <- DT15$HIncome
#
DT15$INCOME_P <- as.numeric(DT15$INCOME_P)
DT15$INCOME_P <- car::recode(DT15$INCOME_P, ' "2"="1"; "3"="1"; "4"="2"; "5"="2"; "6"="3"; "7"="4"; "8"="4"; "9"="4"')
#
table(DT15$HIncome)
table(DT15$INCOME_P)
#
#
#DT17
#
DT17$INCOME_P <- DT17$HIncome
#
DT17[DT17$INCOME_P %in% c(1,2,3,4), "INCOME_P"] <- NA
#
DT17$INCOME_P <- as.numeric(DT17$INCOME_P)
DT17$INCOME_P <- car::recode(DT17$INCOME_P, ' "5"="4"; "6"="4"')
#
table(DT17$HIncome)
table(DT17$INCOME_P)
#
#

```


### IVs - Partisanship & Ideology

```{r PARTISANSHIP}

#DT1
#
DT1$PARTISANSHIP_P <- DT1$PID1
#
DT1[DT1$PARTISANSHIP_P %in% c(98,99), "PARTISANSHIP_P"] <- NA
#
table(DT1$PID1)
table(DT1$PARTISANSHIP_P)
#
#
#DT2
#
DT2$PARTISANSHIP_P <- DT2$PID1
#
DT2[DT2$PARTISANSHIP_P %in% c(98), "PARTISANSHIP_P"] <- NA
#
table(DT2$PID1)
table(DT2$PARTISANSHIP_P)
#
#
#DT5
#
DT5$PARTISANSHIP_P <- DT5$PRTY
#
DT5[DT5$PARTISANSHIP_P %in% c(9), "PARTISANSHIP_P"] <- NA
#
DT5$PARTISANSHIP_P <- as.numeric(DT5$PARTISANSHIP_P)
DT5$PARTISANSHIP_P <- car::recode(DT5$PARTISANSHIP_P, ' "1"="2"; "2"="1"; "3"="4"')
#
table(DT5$PRTY)
table(DT5$PARTISANSHIP_P)
#
#
#DT6
#
DT6$PARTISANSHIP_P <- DT6$QND8
#
DT6[DT6$PARTISANSHIP_P %in% c(9), "PARTISANSHIP_P"] <- NA
#
DT6$PARTISANSHIP_P <- as.numeric(DT6$PARTISANSHIP_P)
DT6$PARTISANSHIP_P <- car::recode(DT6$PARTISANSHIP_P, ' "1"="2";"2"="1";"3"="4";"4"="3"')
#
table(DT6$QND8)
table(DT6$PARTISANSHIP_P)
#
#
#DT7
#
DT7$PARTISANSHIP_P <- DT7$PARTY1
#
DT7[DT7$PARTISANSHIP_P %in% c(9), "PARTISANSHIP_P"] <- NA
#
DT7$PARTISANSHIP_P <- as.numeric(DT7$PARTISANSHIP_P)
DT7$PARTISANSHIP_P <- car::recode(DT7$PARTISANSHIP_P, '"1"="2";"2"="1";"3"="4";"4"="3" ')
#
table(DT7$PARTY1)
table(DT7$PARTISANSHIP_P)
#
#
#DT8
#
DT8$PARTISANSHIP_P <- DT8$PARTY1
#
DT8[DT8$PARTISANSHIP_P %in% c(9), "PARTISANSHIP_P"] <- NA
#
DT8$PARTISANSHIP_P <- as.numeric(DT8$PARTISANSHIP_P)
DT8$PARTISANSHIP_P <- car::recode(DT8$PARTISANSHIP_P, '"1"="2";"2"="1";"3"="4";"4"="3"')
#
table(DT8$PARTY1)
table(DT8$PARTISANSHIP_P)
#
#
#DT9
#
DT9$PARTISANSHIP_P <- DT9$PARTY
#
DT9[DT9$PARTISANSHIP_P %in% c(8,9), "PARTISANSHIP_P"] <- NA
#
DT9$PARTISANSHIP_P <- as.numeric(DT9$PARTISANSHIP_P)
DT9$PARTISANSHIP_P <- car::recode(DT9$PARTISANSHIP_P, '"1"="2";"2"="1";"3"="4";"4"="3"')
#
table(DT9$PARTY)
table(DT9$PARTISANSHIP_P)
#
#
#DT11
#
DT11$PARTISANSHIP_P <- DT11$PARTYID
#
DT11[DT11$PARTISANSHIP_P %in% c(9), "PARTISANSHIP_P"] <- NA
#
DT11$PARTISANSHIP_P <- as.numeric(DT11$PARTISANSHIP_P)
DT11$PARTISANSHIP_P <- car::recode(DT11$PARTISANSHIP_P, '"1"="2";"2"="1";"3"="4";"7"="3"')
#
table(DT11$PARTYID)
table(DT11$PARTISANSHIP_P)
#
#
#DT12
#
DT12$PARTISANSHIP_P <- DT12$PARTYID
#
DT12[DT12$PARTISANSHIP_P %in% c(9), "PARTISANSHIP_P"] <- NA
#
DT12$PARTISANSHIP_P <- as.numeric(DT12$PARTISANSHIP_P)
DT12$PARTISANSHIP_P <- car::recode(DT12$PARTISANSHIP_P, '"1"="2";"2"="1";"3"="4";"7"="3"')
#
table(DT12$PARTYID)
table(DT12$PARTISANSHIP_P)
#
#
#DT3
#
DT13$PARTISANSHIP_P <- DT13$PARTY
#
DT13[DT13$PARTISANSHIP_P %in% c(4,9), "PARTISANSHIP_P"] <- NA
#
DT13$PARTISANSHIP_P <- as.numeric(DT13$PARTISANSHIP_P)
DT13$PARTISANSHIP_P <- car::recode(DT13$PARTISANSHIP_P, '"1"="2";"2"="1";"3"="4";"5"="3"')
#
table(DT13$PARTY)
table(DT13$PARTISANSHIP_P)
#
#
#DT14
#
DT14$PARTISANSHIP_P <- DT14$F_PARTY_
#
DT14[DT14$PARTISANSHIP_P %in% c(99), "PARTISANSHIP_P"] <- NA
#
DT14$PARTISANSHIP_P <- as.numeric(DT14$PARTISANSHIP_P)
DT14$PARTISANSHIP_P <- car::recode(DT14$PARTISANSHIP_P, '"1"="2";"2"="1";"3"="4";"4"="3"')
#
table(DT14$F_PARTY_)
table(DT14$PARTISANSHIP_P)
#
#
#DT15
#
DT15$PARTISANSHIP_P <- DT15$F_PARTY_FINAL
#
DT15[DT15$PARTISANSHIP_P %in% c(99), "PARTISANSHIP_P"] <- NA
#
DT15$PARTISANSHIP_P <- as.numeric(DT15$PARTISANSHIP_P)
DT15$PARTISANSHIP_P <- car::recode(DT15$PARTISANSHIP_P, '"1"="2";"2"="1";"3"="4";"4"="3"')
#
table(DT15$F_PARTY_FINAL)
table(DT15$PARTISANSHIP_P)
#
#
#DT17
#
DT17$PARTISANSHIP_P <- DT17$QN24
#
DT17[DT17$PARTISANSHIP_P %in% c(8,9), "PARTISANSHIP_P"] <- NA
#
DT17$PARTISANSHIP_P <- as.numeric(DT17$PARTISANSHIP_P)
DT17$PARTISANSHIP_P <- car::recode(DT17$PARTISANSHIP_P, ' "3"="4"; "4"="3"')
#
table(DT17$QN24)
table(DT17$PARTISANSHIP_P)
#
#
#
#

```


```{r IDEOLOGY}

#DT1
#
DT1$IDEOLOGY_P <- DT1$Ideol_Conservative
#
table(DT1$Ideol_Conservative)
table(DT1$IDEOLOGY_P)
#
#
#DT2
#
DT2$IDEOLOGY_P <- DT2$Ideol_Conservative
#
table(DT2$Ideol_Conservative)
table(DT2$IDEOLOGY_P)
#
#
#DT5
#
DT5$IDEOLOGY_P <- DT5$Ideol_Conservative
#
#
table(DT5$Ideol_Conservative)
table(DT5$IDEOLOGY_P)
#
#
#DT6
#
DT6$IDEOLOGY_P <- DT6$Ideol_Conservative
#
table(DT6$Ideol_Conservative)
table(DT6$IDEOLOGY_P)
#
#
#DT7
#
DT7$IDEOLOGY_P <- DT7$Ideol_Conservative
#
table(DT7$Ideol_Conservative)
table(DT7$IDEOLOGY_P)
#
#
#DT8
#
DT8$IDEOLOGY_P <- DT8$Ideol_Conservative
#
#
table(DT8$Ideol_Conservative)
table(DT8$IDEOLOGY_P)
#
#
#DT9
#
DT9$IDEOLOGY_P <- DT9$Ideol_Conservative
#
table(DT9$Ideol_Conservative)
table(DT9$IDEOLOGY_P)
#
#
#DT11
DT11$IDEOLOGY_P <- NA
#
#
#DT12
DT12$IDEOLOGY_P <- NA
#
#
#DT3
#
DT13$IDEOLOGY_P <- DT13$IDEO
#
DT13[DT13$IDEOLOGY_P %in% c(9), "IDEOLOGY_P"] <- NA
#
DT13$IDEOLOGY_P <- as.numeric(DT13$IDEOLOGY_P)
DT13$IDEOLOGY_P <- car::recode(DT13$IDEOLOGY_P, ' "4"="1"; "5"="1"; "3"="2"; "1"="3"; "2"="3"')
#
table(DT13$IDEO)
table(DT13$IDEOLOGY_P)
#
#
#DT14
#
DT14$IDEOLOGY_P <- DT14$F_IDEO_F
#
DT14[DT14$IDEOLOGY_P %in% c(99), "IDEOLOGY_P"] <- NA
#
DT14$IDEOLOGY_P <- as.numeric(DT14$IDEOLOGY_P)
DT14$IDEOLOGY_P <- car::recode(DT14$IDEOLOGY_P, ' "4"="1"; "5"="1"; "3"="2"; "1"="3"; "2"="3"')
#
table(DT14$F_IDEO_F)
table(DT14$IDEOLOGY_P)
#
#
#DT15
#
DT15$IDEOLOGY_P <- DT15$F_IDEO
#
DT15[DT15$IDEOLOGY_P %in% c(99), "IDEOLOGY_P"] <- NA
#
DT15$IDEOLOGY_P <- as.numeric(DT15$IDEOLOGY_P)
DT15$IDEOLOGY_P <- car::recode(DT15$IDEOLOGY_P, ' "4"="1"; "5"="1"; "3"="2"; "1"="3"; "2"="3"')
#
table(DT15$F_IDEO)
table(DT15$IDEOLOGY_P)
#
#
#DT17
#
DT17$IDEOLOGY_P <- DT17$QN51
#
DT17[DT17$IDEOLOGY_P %in% c(4,8,9), "IDEOLOGY_P"] <- NA
#
table(DT17$QN51)
table(DT17$IDEOLOGY_P)
#
#
#
#

```

### Merging 

```{r}
DT.all <- rbind(DT1[,c("BLM_supp", "RACE_P", "GENDER_P", "AGE_P", "EDUCATION_P", "URBANICITY_P", "RELIGION_P", "MARITAL_P",  "EMPLOYMENT_P", "INCOME_P", "PARTISANSHIP_P", "IDEOLOGY_P")],
                DT2[,c("BLM_supp", "RACE_P", "GENDER_P", "AGE_P", "EDUCATION_P", "URBANICITY_P", "RELIGION_P", "MARITAL_P",  "EMPLOYMENT_P", "INCOME_P", "PARTISANSHIP_P", "IDEOLOGY_P")],
                DT5[,c("BLM_supp", "RACE_P", "GENDER_P", "AGE_P", "EDUCATION_P", "URBANICITY_P", "RELIGION_P", "MARITAL_P",  "EMPLOYMENT_P", "INCOME_P", "PARTISANSHIP_P", "IDEOLOGY_P")],
                DT6[,c("BLM_supp", "RACE_P", "GENDER_P", "AGE_P", "EDUCATION_P", "URBANICITY_P", "RELIGION_P", "MARITAL_P",  "EMPLOYMENT_P", "INCOME_P", "PARTISANSHIP_P", "IDEOLOGY_P")],
                DT7[,c("BLM_supp", "RACE_P", "GENDER_P", "AGE_P", "EDUCATION_P", "URBANICITY_P", "RELIGION_P", "MARITAL_P",  "EMPLOYMENT_P", "INCOME_P", "PARTISANSHIP_P", "IDEOLOGY_P")],
                DT8[,c("BLM_supp", "RACE_P", "GENDER_P", "AGE_P", "EDUCATION_P", "URBANICITY_P", "RELIGION_P", "MARITAL_P",  "EMPLOYMENT_P", "INCOME_P", "PARTISANSHIP_P", "IDEOLOGY_P")],
                DT9[,c("BLM_supp", "RACE_P", "GENDER_P", "AGE_P", "EDUCATION_P", "URBANICITY_P", "RELIGION_P", "MARITAL_P",  "EMPLOYMENT_P", "INCOME_P", "PARTISANSHIP_P", "IDEOLOGY_P")],
                DT11[,c("BLM_supp", "RACE_P", "GENDER_P", "AGE_P", "EDUCATION_P", "URBANICITY_P", "RELIGION_P", "MARITAL_P",  "EMPLOYMENT_P", "INCOME_P", "PARTISANSHIP_P", "IDEOLOGY_P")],
                DT12[,c("BLM_supp", "RACE_P", "GENDER_P", "AGE_P", "EDUCATION_P", "URBANICITY_P", "RELIGION_P", "MARITAL_P",  "EMPLOYMENT_P", "INCOME_P", "PARTISANSHIP_P", "IDEOLOGY_P")],
                DT13[,c("BLM_supp", "RACE_P", "GENDER_P", "AGE_P", "EDUCATION_P", "URBANICITY_P", "RELIGION_P", "MARITAL_P",  "EMPLOYMENT_P", "INCOME_P", "PARTISANSHIP_P", "IDEOLOGY_P")],
                DT14[,c("BLM_supp", "RACE_P", "GENDER_P", "AGE_P", "EDUCATION_P", "URBANICITY_P", "RELIGION_P", "MARITAL_P",  "EMPLOYMENT_P", "INCOME_P", "PARTISANSHIP_P", "IDEOLOGY_P")],
                DT15[,c("BLM_supp", "RACE_P", "GENDER_P", "AGE_P", "EDUCATION_P", "URBANICITY_P", "RELIGION_P", "MARITAL_P",  "EMPLOYMENT_P", "INCOME_P", "PARTISANSHIP_P", "IDEOLOGY_P")],
                DT17[,c("BLM_supp", "RACE_P", "GENDER_P", "AGE_P", "EDUCATION_P", "URBANICITY_P", "RELIGION_P", "MARITAL_P",  "EMPLOYMENT_P", "INCOME_P", "PARTISANSHIP_P", "IDEOLOGY_P")])
#
#
#
sapply(DT.all, table)
```

### Percentages

#### Variables

```{r}
library(dplyr)
#
DT.all$BLM_supp  <- factor(DT.all$BLM_supp, labels = c("Oppose", "Support"))
#
#
## RACE & ETHNICITY
#-------------------
#
plyr::count(DT.all, c("BLM_supp", "RACE_P"))
#
DT.all.Race <- plyr::count(DT.all, c("BLM_supp", "RACE_P"))
#
# Remove NAs
DT.all.Race <- DT.all.Race[complete.cases(DT.all.Race),]
#
# c("White Americans", "African Americans", "Latinos", "Asian Americans")
DT.all.Race$RACE_P <- car::recode(DT.all.Race$RACE_P, ' "1"="1";"2"="4";"3"="2";"4"="3"')
#
DT.all.Race <- DT.all.Race[with(DT.all.Race, order(BLM_supp, RACE_P)),]
#
DT.all.Race$RACE_P  <- factor(DT.all.Race$RACE_P, labels = c("White Americans", "Latinos", "Asian Americans","African Americans"))
#
names(DT.all.Race)[2] <- "variable"
#
DT.all.Race %>% group_by(variable) %>% mutate(perc = prop.table(freq)) -> DT.all.Race
#
#
#
## GENDER
#-------------
plyr::count(DT.all, c("BLM_supp", "GENDER_P"))  # unique values: 1 and 2
#
DT.all.Gender <- plyr::count(DT.all, c("BLM_supp", "GENDER_P"))
#
# Remove NAs
DT.all.Gender <- DT.all.Gender[complete.cases(DT.all.Gender),]
#
DT.all.Gender$GENDER_P   <- factor(DT.all.Gender$GENDER_P, labels = c("Male", "Female"))
#
names(DT.all.Gender)[2] <- "variable"
#
DT.all.Gender %>% group_by(variable) %>% mutate(perc = prop.table(freq)) -> DT.all.Gender
#
#
#
## AGE
#
plyr::count(DT.all, c("BLM_supp", "AGE_P")) # unique values: 0 and 1
#
DT.all.Age <- plyr::count(DT.all, c("BLM_supp", "AGE_P"))
#
# Remove NAs
DT.all.Age <- DT.all.Age[complete.cases(DT.all.Age),]
#

DT.all.Age$AGE_P <- factor(DT.all.Age$AGE_P, labels = c("18-29", "30-49","50-64", "65+"))
#
names(DT.all.Age)[2] <- "variable"
#
DT.all.Age %>% group_by(variable) %>% mutate(perc = prop.table(freq)) -> DT.all.Age
#
#
#
#
## EDUCATION
#
plyr::count(DT.all, c("BLM_supp", "EDUCATION_P")) # unique values: 0 and 1
#
DT.all.Education <- plyr::count(DT.all, c("BLM_supp", "EDUCATION_P"))
#
# Remove NAs
DT.all.Education <- DT.all.Education[complete.cases(DT.all.Education),]
#
DT.all.Education$EDUCATION_P <- factor(DT.all.Education$EDUCATION_P, labels = c("Less than High School", "High School","Some college, no degree", "College", "Post-Grad"))
#
names(DT.all.Education)[2] <- "variable"
#
DT.all.Education %>% group_by(variable) %>% mutate(perc = prop.table(freq)) -> DT.all.Education
#
#
#
## URBANICITY
#
plyr::count(DT.all, c("BLM_supp", "URBANICITY_P"))  # unique values: 1 and 2
#
DT.all.Urbanicity <- plyr::count(DT.all, c("BLM_supp", "URBANICITY_P"))
#
# Remove NAs
DT.all.Urbanicity <- DT.all.Urbanicity[complete.cases(DT.all.Urbanicity),]
#

DT.all.Urbanicity$URBANICITY_P   <- factor(DT.all.Urbanicity$URBANICITY_P, labels = c("Non-Metropolitan area", "Metropolitan area"))
#
names(DT.all.Urbanicity)[2] <- "variable"
#
DT.all.Urbanicity %>% group_by(variable) %>% mutate(perc = prop.table(freq)) -> DT.all.Urbanicity
#
#
#
## RELIGION
#-----------
plyr::count(DT.all, c("BLM_supp", "RELIGION_P")) # unique values: 0 and 1
#
DT.all.Religion <- plyr::count(DT.all, c("BLM_supp", "RELIGION_P"))
#
# Remove NAs
DT.all.Religion <- DT.all.Religion[complete.cases(DT.all.Religion),]
#
DT.all.Religion$RELIGION_P <- car::recode(DT.all.Religion$RELIGION_P, ' "1"="2";"2"="1" ')
#
DT.all.Religion <- DT.all.Religion[with(DT.all.Religion, order(BLM_supp, RELIGION_P)),]
#
DT.all.Religion$RELIGION_P <- factor(DT.all.Religion$RELIGION_P, labels = c("Roman Catholic", "Protestant", "Jewish", "Other", "None"))
#
names(DT.all.Religion)[2] <- "variable"
#
DT.all.Religion %>% group_by(variable) %>% mutate(perc = prop.table(freq)) -> DT.all.Religion
#
#
#
#
#
#
#
# ## MARITAL STATUS
#
plyr::count(DT.all, c("BLM_supp", "MARITAL_P")) # unique values: 0 and 1
#
DT.all.Marital <- plyr::count(DT.all, c("BLM_supp", "MARITAL_P"))
#
# Remove NAs
DT.all.Marital <- DT.all.Marital[complete.cases(DT.all.Marital),]
#

DT.all.Marital$MARITAL_P <- factor(DT.all.Marital$MARITAL_P, labels = c("Married", "Widowed","Divorced", "Separated", "Living with partner", "Single/Never Married"))
#
names(DT.all.Marital)[2] <- "variable"
#
DT.all.Marital %>% group_by(variable) %>% mutate(perc = prop.table(freq)) -> DT.all.Marital
#
#
#
# 
#
# ## EMPLOYMENT STATUS
#
plyr::count(DT.all, c("BLM_supp", "EMPLOYMENT_P")) # unique values: 0 and 1
#
DT.all.Employment <- plyr::count(DT.all, c("BLM_supp", "EMPLOYMENT_P"))
#
# Remove NAs
DT.all.Employment <- DT.all.Employment[complete.cases(DT.all.Employment),]
#
#
DT.all.Employment$EMPLOYMENT_P <- car::recode(DT.all.Employment$EMPLOYMENT_P, '  "1"="2";"2"="1"  ')
#
DT.all.Employment <- DT.all.Employment[with(DT.all.Employment, order(BLM_supp, EMPLOYMENT_P)),]
#
DT.all.Employment$EMPLOYMENT_P <- factor(DT.all.Employment$EMPLOYMENT_P, labels = c("Not Working/Not Employed", "Working/Employed", "Disabled", "Retired"))
#
names(DT.all.Employment)[2] <- "variable"
#
DT.all.Employment %>% group_by(variable) %>% mutate(perc = prop.table(freq)) -> DT.all.Employment
#
#
#
## INCOME
#
plyr::count(DT.all, c("BLM_supp", "INCOME_P"))  # unique values: 1 and 2
#
DT.all.Income <- plyr::count(DT.all, c("BLM_supp", "INCOME_P"))
#
# Remove NAs
DT.all.Income <- DT.all.Income[complete.cases(DT.all.Income),]
#

DT.all.Income$INCOME_P   <- factor(DT.all.Income$INCOME_P, labels = c("Less than 30k", "30k-50k", "50k-75k", "75k"))
#
names(DT.all.Income)[2] <- "variable"
#
DT.all.Income %>% group_by(variable) %>% mutate(perc = prop.table(freq)) -> DT.all.Income
#
#
#
#
#
###--------------------
###### PARTISANSHIP
###------------------
plyr::count(DT.all, c("BLM_supp", "PARTISANSHIP_P"))  # unique values: 1 and 2
#
DT.all.Partisanship <- plyr::count(DT.all, c("BLM_supp", "PARTISANSHIP_P"))
#
# Remove NAs
DT.all.Partisanship <- DT.all.Partisanship[complete.cases(DT.all.Partisanship),]
#
# c("Democrat", "Republican", "Something else", "Independent")
DT.all.Partisanship$PARTISANSHIP_P <- labelled::remove_labels(DT.all.Partisanship$PARTISANSHIP_P)
#
DT.all.Partisanship$PARTISANSHIP_P <- car::recode(DT.all.Partisanship$PARTISANSHIP_P, ' "1"="1";"2"="3";"3"="4";"4"="2"')
#
DT.all.Partisanship <- DT.all.Partisanship[with(DT.all.Partisanship, order(BLM_supp, PARTISANSHIP_P)),]
#
DT.all.Partisanship$PARTISANSHIP_P  <- factor(DT.all.Partisanship$PARTISANSHIP_P, labels = c("Democrat", "Independent", "Republican", "Something else"))
#
names(DT.all.Partisanship)[2] <- "variable"
#
DT.all.Partisanship %>% group_by(variable) %>% mutate(perc = prop.table(freq)) -> DT.all.Partisanship
# 
#
#
## Ideology
#----------------
plyr::count(DT.all, c("BLM_supp", "IDEOLOGY_P"))  # unique values: 1 and 2
#
DT.all.Ideology <- plyr::count(DT.all, c("BLM_supp", "IDEOLOGY_P"))
#
# Remove NAs
DT.all.Ideology <- DT.all.Ideology[complete.cases(DT.all.Ideology),]
#

DT.all.Ideology$IDEOLOGY_P   <- factor(DT.all.Ideology$IDEOLOGY_P, labels = c("Liberal", "Moderate", "Conservative"))
#
names(DT.all.Ideology)[2] <- "variable"
#
DT.all.Ideology %>% group_by(variable) %>% mutate(perc = prop.table(freq)) -> DT.all.Ideology
#

#
dt <- rbind(DT.all.Race, DT.all.Gender, DT.all.Age, DT.all.Education, DT.all.Income, DT.all.Urbanicity, DT.all.Religion, DT.all.Marital, DT.all.Employment, DT.all.Partisanship,DT.all.Ideology)
#
#
#library(dplyr)
#library(ggplot2)
#library(tidyr)
#library(scales)  # for percentage scales
#
# this works for counts
# ggplot(data = dt, aes(x = variable, y = freq, fill = BLM_supp)) +
#   geom_col() +
#   geom_text(aes(label = freq),
#             position = position_stack(vjust = .5))
#
#
#save.image("radialplot.RData")
#
# ggplot(dt, aes(fill=BLM_supp, y=perc, x=variable)) + 
#   geom_bar(position="fill", stat="identity") +
#   labs(x="", y="") +
#   theme_minimal() +
#   geom_text(aes(label=paste0(round(100*perc,1),"%")),
#             position = position_stack(vjust = .5), family = "Georgia") +
#   #scale_y_continuous(breaks = seq(0, 1, by = 0.1)) +
#   theme(text = element_text(size=11, family = "Georgia"),
#         plot.title    = element_text(size=13, family = "Georgia"),
#         plot.subtitle = element_text(size=12, family = "Georgia", face = "italic"),
#         plot.caption  = element_text(family = "Georgia", color = "#383838", face = "italic", size = 7),
#         axis.text.x   = element_text(angle = 0, hjust = 1),
#         legend.title  = element_blank(),
#         legend.position = "bottom") +
#    coord_polar(start = 0)


```

# Multiple Linear Regressions and Elastic Nets

```{r}
library(caret)
library(glmnet)
#
# ----------------------------------
# Code to loop across all datasets
# ----------------------------------
#
# Set training control
D1.train_cont <- trainControl(method = "repeatedcv", number = 10, repeats = 5, search = "random", verboseIter = F)
#
# Train the model
D1.elastic_reg <- train(BLM_supp ~ ., data = D1.noNA, method = "glmnet", 
                        na.action = na.omit,
                        preProc = c("center", "scale", "zv", "nzv"), 
                        tuneLength = 10, 
                        trControl = D1.train_cont)
#
#alpha = 0.7956364 and lambda = 0.03088109.
#
D1.elastic <- glmnet(x = as.matrix(D1.noNA[complete.cases(D1.noNA),-c(1)]),
                  y = D1.noNA[complete.cases(D1.noNA), c("BLM_supp")],
                  alpha  = alpha, 
                  lambda = lambda)
#
#
# Multiple Linear Regression using only significant variables from Elastic Nets
#
D1.m.EN <- lm(BLM_supp ~ REducation + RGender + Race_Blacks + Ideol_Conservative + VoteHR_Republicans + Trump_App + MexicoWall + Immigration_Illegal + SystematicRacism , data = D1)
#
D1.m.EN.             <- broom::tidy(D1.m.EN) 
#
# Do this for all datasets
```


```{r setting up Figure 5 plot with all sig coefs}
D.m.EN_sig.all <- rbind(
  D1.m.EN.,
  D2.m.EN.,
  D5.m.EN.,
  D6.m.EN.,  
  D7.m.EN.,  
  D8.m.EN.,  
  D9.m.EN.,
  D11.m.EN.,
  D12.m.EN.,
  #D13.m.EN.,
  D14.m.EN.,
  D15.m.EN.,
  D17.m.EN.)
#
#
D.m.EN.selected <- c(as.character(D1.tmp_coeffs$name),as.character(D2.tmp_coeffs$name),as.character(D5.tmp_coeffs$name),as.character(D6.tmp_coeffs$name),as.character(D7.tmp_coeffs$name),as.character(D8.tmp_coeffs$name),as.character(D9.tmp_coeffs$name),as.character(D11.tmp_coeffs$name),as.character(D12.tmp_coeffs$name),as.character(D14.tmp_coeffs$name),as.character(D15.tmp_coeffs$name),as.character(D17.tmp_coeffs$name))
#
D.m.all <- data.frame(table(c(names(D1.noNA),names(D2.noNA),names(D5.noNA),names(D6.noNA),names(D7.noNA),names(D8.noNA),names(D9.noNA),names(D11.noNA),names(D12.noNA),names(D13.noNA),names(D14.noNA),names(D15.noNA),names(D17.noNA))))
names(D.m.all) <- c("variable", "Freq")
#
D.m.EN.selected.tb <- data.frame(table(D.m.EN.selected))
names(D.m.EN.selected.tb) <- c("variable", "Freq_sel")
#
D.m.EN_sig.all.tb <- data.frame(table(D.m.EN_sig.all$term))
names(D.m.EN_sig.all.tb) <- c("variable", "Freq_sig")
#
df.EN.results.temp     <- dplyr::left_join(D.m.all, D.m.EN.selected.tb)
df.EN.results.temp1    <- dplyr::left_join(df.EN.results.temp, D.m.EN_sig.all.tb)
df.EN.results.temp1    <- df.EN.results.temp1[-3,]
# adding D6
df.EN.results.temp1[df.EN.results.temp1$variable %in% c("RGender", "Race_Blacks", "PersDiscr", "RacialDisc", "Partisanship_Rep", "Ideol_Conservative"), "Freq_sel"] <- c(9L, 11L, 3L, 10L, 2L, 11L) + 1L
#
df.EN.results.temp1$`%` <- round(df.EN.results.temp1$Freq_sig/df.EN.results.temp1$Freq,2)
#
#df.EN.results <- df.EN.results.temp[order(-df.EN.results.temp$`%`),]
#
#df.EN.results <- df.EN.results.temp1[with(df.EN.results.temp1, order(-`%`, -Freq_sig)), ]
#
df.EN.results <- df.EN.results.temp1[with(df.EN.results.temp1, order( -Freq_sig)), ]
#dput(as.character(df.EN.results$variable))
#
df.EN.results$variable <- as.character(df.EN.results$variable)
#
df.EN.results$variable <- factor(df.EN.results$variable, levels = c("Ideol_Conservative", "Race_Blacks", "RGender", "REducation", "Partisanship_Rep", "Immigration_Illegal", "Trump_App", "MexicoWall", "Protest_Legit", "VoteHR_Republicans", "Attend_RacialProtest","BidenvsTrump_Race", "PersDiscr", "RacialDisc", "RAge", "Religiosity", "SystematicRacism", "Vote16_ClintonVSTrump", "Country_Econ", "Hillary_Fav", "HIncome", "Obama_App", "PoliceMisc", "Race_Hisp", "Trump_Fav", "Urbanicity", "Vote2020_TrumpvsBiden", "Country_Future", "EmploymentStatus", "Immigration_Jobs", "MaritalStatus", "Pers_Finances","Race_Asians", "Race_Whites", "RaceRelations_Better", "VoteInt", "VoteReg"),
                                 labels = c("Conservatism (3-point IID)", "Blacks (vs Other Races)", "Female (vs Male)", "Education", "Republican (3-point PID)", "Illegal immigrants should leave U.S.", "Approval of Trump's Presidency", "Support for Building the Wall", "BLM Legitimacy", "Vote Intention House (Republicans)", "Racial Equality Protesting", "Biden's Handling of Racial Tensions", "Experienced Discrimination", "Blacks are discriminated against", "Age", "Religiosity", "Perceived Systematic Racism", "Trump Vote Intention 2016 (vs Clinton)", "U.S. Economy is Going Well", "Favorability towards Clinton", "Income", "Approval of Obama's Presidency", "Racially Motivated Police Misconduct", "Hispanics (vs Other Races)", "Favorability towards Trump", "Urbanicity", "Trump Vote Intention 2020 (vs Biden)", "Optimism about U.S. Future", "Employed (vs Retired)", "Immigrants Take Jobs Away", "Married (vs Single)", "Optimism about Personal Finances", "Asians (vs Other Races)", "Whites (vs Other Races)", "Race Relations Are Getting Better", "Intention to Vote", "Registered to Vote"))
#
df.EN.results.melt <-  reshape2::melt(df.EN.results)
names(df.EN.results.melt) <- c("variable", "type", "value")
#
df.EN.results.melt <- df.EN.results.melt[df.EN.results.melt$type %in% c("Freq", "Freq_sig", "Freq_sel"), ]
#
df.EN.results.melt[is.na(df.EN.results.melt$value),"value"] <- 0
#
#
#
#
#
#
#
#
df.EN.results.melt1 <-  reshape2::melt(df.EN.results)
names(df.EN.results.melt1) <- c("variable", "type", "value")
#
df.EN.results.melt1 <- df.EN.results.melt1[df.EN.results.melt1$type %in% c("Freq", "Freq_sig"), ]
#
df.EN.results.melt1[is.na(df.EN.results.melt1$value),"value"] <- 0
#
#df.EN.results.melt1$type <- as.character(df.EN.results.melt1$type)
#df.EN.results.melt1$type <- as.factor(df.EN.results.melt1$type)
#df.EN.results.melt1$type <- forcats::fct_rev(df.EN.results.melt1$type)
#
```


```{r Figure 5 plot with all sig coefs}
draw_key_polygon3 <- function(data, params, size) {
  lwd <- min(data$size, min(size) / 4)
  
  grid::rectGrob(
    width = grid::unit(0.7, "npc"),
    height = grid::unit(0.7, "npc"),
    gp = grid::gpar(
      col = data$colour,
      fill = alpha(data$fill, data$alpha),
      lty = data$linetype,
      lwd = lwd * .pt,
      linejoin = "mitre"
    ))
}


############
# Panel A
############
ggplot(df.EN.results.melt1, aes(x=variable, y=value, fill=type)) + 
  geom_bar(key_glyph = "polygon3", position="dodge", stat="identity") +
  scale_x_discrete(limits = rev(levels(df.EN.results.melt1$variable))) +
  scale_y_continuous(breaks = scales::pretty_breaks(n = 13)) +
  scale_fill_manual(values=c("#d0d0d0","#500000"), 
                    labels=c("Number of times a variable is\npresent across datasets",
                             "Number of times a variable is a statistically\nsignificant predictor of BLM support")) +
  coord_flip() +
  labs(y="\nCounts",
       x="",
        fill='',
       title = "") +
  theme_minimal(base_size = 11, 
                base_family = "Georgia") + 
  guides(fill = guide_legend(reverse=TRUE)) +
  theme(text = element_text(size=11, family = "Georgia"),
        #legend.position="bottom",
        legend.position = c(0.65,0.76),
        legend.text=element_text(size=8),
        panel.grid.minor.x = element_blank(),
        plot.title    = element_text(size=13, family = "Georgia"),
        plot.subtitle = element_text(size=12, family = "Georgia", face = "italic"))
#
#
#
#
#
#
#
#
############
# Panel B
############
#
D1.m.EN.std   <- parameters::model_parameters(D1.m.EN, standardize = "refit")
D2.m.EN.std   <- parameters::model_parameters(D2.m.EN, standardize = "refit")
D5.m.EN.std   <- parameters::model_parameters(D5.m.EN, standardize = "refit")
D6.m.EN.std   <- parameters::model_parameters(D6.m.EN, standardize = "refit")
D7.m.EN.std   <- parameters::model_parameters(D7.m.EN, standardize = "refit")
D8.m.EN.std   <- parameters::model_parameters(D8.m.EN, standardize = "refit")
D9.m.EN.std   <- parameters::model_parameters(D9.m.EN, standardize = "refit")
D11.m.EN.std  <- parameters::model_parameters(D11.m.EN, standardize = "refit")
D12.m.EN.std  <- parameters::model_parameters(D12.m.EN, standardize = "refit")
D13.m.EN.std  <- parameters::model_parameters(D13.m.EN, standardize = "refit")
D14.m.EN.std  <- parameters::model_parameters(D14.m.EN, standardize = "refit")
D15.m.EN.std  <- parameters::model_parameters(D15.m.EN, standardize = "refit")
D17.m.EN.std  <- parameters::model_parameters(D17.m.EN, standardize = "refit")
#
D1.m.EN.std.ALL <-rbind(D1.m.EN.std,D2.m.EN.std,D5.m.EN.std,D6.m.EN.std,D7.m.EN.std,D8.m.EN.std,D9.m.EN.std,D11.m.EN.std, D12.m.EN.std,D13.m.EN.std,D14.m.EN.std,D15.m.EN.std,D17.m.EN.std)
#
D1.m.EN.std.ALL <- data.frame(D1.m.EN.std.ALL)
D1.m.EN.std.ALL <- D1.m.EN.std.ALL[D1.m.EN.std.ALL$Parameter %!in% c("(Intercept)"),]
#
#dput(names(D1.m.EN.std.ALL))
#c("Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high","t", "df_error", "p")
#
D1.m.EN.std.ALL$Parameter2 <- D1.m.EN.std.ALL$Parameter
library(dplyr)
D1.m.EN.std.ALL %>%
    group_by(Parameter) %>%
    dplyr::summarize(
      Coef_Mean    = mean(Coefficient, na.rm=TRUE),
      count = n(),
      CI_low_Mean  = mean(CI_low, na.rm=TRUE),
      CI_high_Mean = mean(CI_high, na.rm=TRUE)) -> D1.m.EN.std.ALL.plot
#
D1.m.EN.std.ALL.plot <- as.data.frame(D1.m.EN.std.ALL.plot)
#
D1.m.EN.std.ALL.plot$Parameter2 <- factor(D1.m.EN.std.ALL.plot$Parameter, levels = c("Ideol_Conservative", "Race_Blacks", "RGender", "REducation", "Partisanship_Rep", "Immigration_Illegal", "Trump_App", "MexicoWall", "Protest_Legit", "VoteHR_Republicans", "Attend_RacialProtest","BidenvsTrump_Race", "PersDiscr", "RacialDisc", "RAge", "Religiosity", "SystematicRacism", "Vote16_ClintonVSTrump", "Country_Econ", "Hillary_Fav", "HIncome", "Obama_App", "PoliceMisc", "Race_Hisp", "Trump_Fav", "Urbanicity", "Vote2020_TrumpvsBiden", "Country_Future", "EmploymentStatus", "Immigration_Jobs", "MaritalStatus", "Pers_Finances","Race_Asians", "Race_Whites", "RaceRelations_Better", "VoteInt", "VoteReg"),
                                 labels = c("Conservatism (3-point IID)", "Blacks (vs Other Races)", "Female (vs Male)", "Education", "Republican (3-point PID)", "Illegal immigrants should leave U.S.", "Approval of Trump's Presidency", "Support for Building the Wall", "BLM Legitimacy", "Vote Intention House (Republicans)", "Racial Equality Protesting", "Biden's Handling of Racial Tensions", "Experienced Discrimination", "Blacks are discriminated against", "Age", "Religiosity", "Perceived Systematic Racism", "Trump Vote Intention 2016 (vs Clinton)", "U.S. Economy is Going Well", "Favorability towards Clinton", "Income", "Approval of Obama's Presidency", "Racially Motivated Police Misconduct", "Hispanics (vs Other Races)", "Favorability towards Trump", "Urbanicity", "Trump Vote Intention 2020 (vs Biden)", "Optimism about U.S. Future", "Employed (vs Retired)", "Immigrants Take Jobs Away", "Married (vs Single)", "Optimism about Personal Finances", "Asians (vs Other Races)", "Whites (vs Other Races)", "Race Relations Are Getting Better", "Intention to Vote", "Registered to Vote"))
#
D1.m.EN.std.ALL.plot$Parameter2 <- forcats::fct_rev(D1.m.EN.std.ALL.plot$Parameter2)
#
ggplot(data=D1.m.EN.std.ALL.plot, 
       aes(x=Coef_Mean, y=Parameter2)) +
  geom_errorbarh(aes(xmin=CI_low_Mean, xmax=CI_high_Mean, color=Parameter2, alpha=(count+0.5))) +
  geom_point(aes(color=Parameter2, alpha=(count+0.5))) +
  scale_color_manual(values=rep(c("#000000"),27)) +
  labs(x="\nStandardized Regression Coefficients", y="", title = "") +
  scale_x_continuous(limits = c(-0.6, 0.6), breaks = scales::pretty_breaks(n = 12)) +
  geom_vline(xintercept=c(0), color = "#500000", size=.5, alpha=0.6) +
  theme_minimal(base_size = 11, base_family = "Georgia") +   
  theme(text = element_text(size=11, family = "Georgia"),
        plot.title    = element_text(size=13, family = "Georgia"),
        panel.grid.minor.x = element_blank(),
        legend.position = "none",
        plot.subtitle = element_text(size=12, family = "Georgia", face = "italic")) 
#
#
#
#
#
##############################################
# Supplements plot with Elastic Net coefs
###############################################
#
ggplot(df.EN.results.melt, aes(x=variable, y=value, fill=type)) + 
  geom_bar(key_glyph = "polygon3", position="dodge", stat="identity") +
  scale_x_discrete(limits = rev(levels(df.EN.results.melt$variable))) +
  scale_y_continuous(breaks = scales::pretty_breaks(n = 13)) +
  scale_fill_manual(values=c("#d0d0d0", "#1B2631", "#500000"),
                    labels=c("Variable is present across datasets",
                             "Variable is selected as predictor of BLM support\n(using Regularization: Elastic Net)",
                             "Variable is a statistically significant\npredictor of BLM support")) +
  coord_flip() +
  labs(y="\nCounts",
       x="",
        fill='',
       title = "Support for Black Lives Matter") +
  theme_minimal(base_size = 11, 
                base_family = "Georgia") + 
  #guides(fill=FALSE)  + 
  theme(text = element_text(size=11, family = "Georgia"),
        #legend.position="bottom",
        legend.position = c(0.65,0.80),
        legend.text=element_text(size=8),
        legend.spacing.y = unit(4, 'cm'),
        panel.grid.minor.x = element_blank(),
        plot.title    = element_text(size=13, family = "Georgia"),
        plot.subtitle = element_text(size=12, family = "Georgia", face = "italic"))
```


```{r Figure 6}
library(RColorBrewer)
library(ggplot2)
library(sjPlot)
# Define the number of colors you want
nb.cols <- 13
mycolors <- colorRampPalette(brewer.pal(8, "Set1"))(nb.cols)
set3 <- colorRampPalette(brewer.pal('Set3',n=12))
#
plot_models(D1.m.EN,  D2.m.EN,  D5.m.EN,  D6.m.EN,
            D7.m.EN,  D8.m.EN,  D9.m.EN,  D11.m.EN, 
            D12.m.EN, D13.m.EN, D14.m.EN, D15.m.EN,
            D17.m.EN,
            grid = FALSE, 
            p.shape = TRUE,
            std.est = "std2",
            legend.title = "Dataset",
            #axis.lim = c(-0.65, 0.65),
            colors = mycolors, #"#575757",
            #m.labels = c("NORC Midterm-Election 2018 W1", "CNN/NORC 2016 Elections", "Kaiser Poll 2020", "NPR/PBS Aug 2020", "NPR/PBS Sep 2020", "Pew Racial Attitudes 2016", "Pew American Trends 2016","Pew American Trends 2020", "Washington/Kaiser 2018", "NORC Midterm-Election 2018 W3", "CBS/NYT 2016","CNN/Kaiser 2020","CNN/NORC 2016 Debates"),
            #c("NORC Midterm-Election 2018 W1","NORC Midterm-Election 2018 W3", "CBS/NYT 2016","CNN/Kaiser 2020","CNN/NORC 2016 Debates","CNN/NORC 2016 Elections","Kaiser Poll 2020","NPR/PBS Aug 2020","NPR/PBS Sep 2020","Pew Racial Attitudes 2016","Pew American Trends 2016","Pew American Trends 2020","Washington/Kaiser 2018") # IN ORDER
            m.labels = c("NORC Midterm-Election 2018 W1", "Pew Racial Attitudes 2016","Pew American Trends 2016", "Pew American Trends 2020","Washington/Kaiser 2018", "NORC Midterm-Election 2018 W3", "CBS/NYT 2016", "CNN/Kaiser 2020", "CNN/NORC 2016 Debates","CNN/NORC 2016 Elections","Kaiser Poll 2020","NPR/PBS Aug 2020","NPR/PBS Sep 2020"),
            axis.labels = rev(c("Education", "Female (vs Male)", "Blacks (vs other races)","Conservatism (3-point IID)",  "Vote Intention House (Republicans)", "Favorability towards Trump", "Support for Building the Wall", "Illegal immigrants should leave U.S.","Perceived Systematic Racism", "Republican (3-point PID)","Experienced Discrimination", "Blacks are discriminated against","Trump Vote Intention 2016 (vs Clinton)","Approval of Obama's Presidency","Approval of Trump's Presidency","Favorability towards Clinton", "U.S. Economy is Going Well", "Biden's Handling of Racial Tensions", "Racially Motivated Police Misconduct", "BLM Legitimacy", "Hispanics (vs Other Races)","Trump Vote Intention 2020 (vs Biden)","Religiosity","Age",  "Income","Urbanicity","Racial Equality Protesting")),
            dot.size = 3) +
  geom_hline(yintercept=c(0), color = "#500000", size=.5) +
  labs(y="\nStandardized Regression Slopes",
       title = "") +
  theme_bw() +
  #scale_x_continuous(limits = c(-1, 1)) + #coord_cartesian(ylim = c(-0.5, 0.5)) +  #xlim(-1, 1) +
  theme_minimal(base_size = 11, 
                base_family = "Georgia") + 
  #guides(colour=FALSE)  + 
  theme(text = element_text(size=11, family = "Georgia"),
        plot.title    = element_text(size=13, family = "Georgia"),
        plot.subtitle = element_text(size=12, family = "Georgia", face = "italic"))  
```

